更改seaborn热图的xticklabels fontsize

时间:2016-01-10 14:59:03

标签: python matplotlib seaborn

这是我的问题:
我使用sns.clustermap()来绘制7变量的系数 想象一下:

http://i4.tietuku.com/ab10ee8d1983361f.png

  • x / y tickslabel看起来很小(在我的例子中,s1,s2,... s9)

我的尝试

  • label='big ==>没效果
  • plt.tick_params(axis =' both',= =' minor',labelsize = 12)===> cbar lable已更改,但x / y轴看起来相同。

http://i11.tietuku.com/5068224d5bbc7c00.png

添加

我的代码:

 ds =  pd.read_csv("xxxx.csv")
 corr = ds.corr().mul(100).astype(int)

 cmap = sns.diverging_palette(h_neg=210, h_pos=350, s=90, l=30, as_cmap=True)

 sns.clustermap(data=corr_s, annot=True, fmt='d',cmap = "Blues",annot_kws={"size": 16},)

2 个答案:

答案 0 :(得分:31)

在绘制数据之前,请考虑致电sns.set(font_scale=1.4)。这将缩放图例中和轴上的所有字体。

我的情节是从这里开始的, enter image description here

对此,

enter image description here

当然,将缩放比例调整为您认为合适的设置。

代码:

sns.set(font_scale=1.4)
cmap = sns.diverging_palette(h_neg=210, h_pos=350, s=90, l=30, as_cmap=True)
sns.clustermap(data=corr, annot=True, fmt='d', cmap="Blues", annot_kws={"size": 16})

答案 1 :(得分:0)

或者只使用set_xticklabels

g = sns.clustermap(data=corr_s, annot=True, fmt='d',cmap = "Blues")
g.ax_heatmap.set_xticklabels(g.ax_heatmap.get_xmajorticklabels(), fontsize = 16)
相关问题