I am using the clustermap method in the seaborn library and I would like to have the axis labels printed in italics. I don’t think that seaborn allows me to specify the font style, so my question is, is there some way to encode italic font style into the label string? I have tried this, [r'$it{'+i+'}$' for i in data.columns]
, but it does not work. Any help is appreciated!
Advertisement
Answer
Here is how the latex-style formatting could be applied to the iris example:
JavaScript
x
10
10
1
import seaborn as sns
2
3
sns.set_theme(color_codes=True)
4
iris = sns.load_dataset("iris")
5
species = iris.pop("species")
6
g = sns.clustermap(iris)
7
g.ax_heatmap.set_xticklabels([r'$it{' + ticklabel.get_text().replace('_', '\ ') + '}$'
8
for ticklabel in g.ax_heatmap.get_xticklabels()])
9
plt.show()
10