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:
import seaborn as sns sns.set_theme(color_codes=True) iris = sns.load_dataset("iris") species = iris.pop("species") g = sns.clustermap(iris) g.ax_heatmap.set_xticklabels([r'$it{' + ticklabel.get_text().replace('_', '\ ') + '}$' for ticklabel in g.ax_heatmap.get_xticklabels()]) plt.show()