Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 更改xticklabels fontsize的seaborn热图_Python_Matplotlib_Seaborn - Fatal编程技术网

Python 更改xticklabels fontsize的seaborn热图

Python 更改xticklabels fontsize的seaborn热图,python,matplotlib,seaborn,Python,Matplotlib,Seaborn,这是我的问题: 我使用sns.clustermap()绘制了7个变量的系数 图如下: x/y滴答声似乎很小(在我的例子中,s1,s2,…s9) 我的尝试 label='big==>无效 plt.tick_参数(axis='both',which='minor',labelsize=12)==>cbar标签已更改,但x/y轴看起来相同 添加 我的代码: ds = pd.read_csv("xxxx.csv") corr = ds.corr().mul(100).astype(in

这是我的问题:
我使用sns.clustermap()绘制了7个变量的系数
图如下:

  • x/y滴答声似乎很小(在我的例子中,s1,s2,…s9)
我的尝试
  • label='big
    ==>无效
  • plt.tick_参数(axis='both',which='minor',labelsize=12)==>cbar标签已更改,但x/y轴看起来相同

添加 我的代码:

 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},)

在绘制数据之前,请考虑调用
sns.set(font\u scale=1.4)
。这将缩放图例和轴上的所有字体

我的计划是这样的,

对此,

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

代码:


或者只需使用SETxticklabels:

g = sns.clustermap(data=corr_s, annot=True, fmt='d',cmap = "Blues")
g.ax_heatmap.set_xticklabels(g.ax_heatmap.get_xmajorticklabels(), fontsize = 16)
import matplotlib.cm as cm
colors = cm.rainbow(np.linspace(0, 1, corr_s.shape[0]))
for i, ticklabel in enumerate(g.ax_heatmap.xaxis.get_majorticklabels()):
    ticklabel.set_color(colors[i])
要获取标签的不同颜色,请执行以下操作:

g = sns.clustermap(data=corr_s, annot=True, fmt='d',cmap = "Blues")
g.ax_heatmap.set_xticklabels(g.ax_heatmap.get_xmajorticklabels(), fontsize = 16)
import matplotlib.cm as cm
colors = cm.rainbow(np.linspace(0, 1, corr_s.shape[0]))
for i, ticklabel in enumerate(g.ax_heatmap.xaxis.get_majorticklabels()):
    ticklabel.set_color(colors[i])

我们可以给标签换不同的颜色吗?谢谢!这似乎很明显,但您也可以通过使用
sns.set(font\u scale=0.5)
使字体变小,特别是使用小于1的值。我们可以为标签提供不同的颜色吗?非常感谢。这真的很有帮助。我认为这是一个更灵活的解决方案。