【问题标题】:Rotate xticklabels in seaborn clutstermap在 seaborn clutstermap 中旋转 xticklabels
【发布时间】:2021-04-27 07:52:21
【问题描述】:

我正在尝试在 seaborn 集群地图中旋转我的 xticklabels,并且我已经尝试了其他帖子的解决方案,但我永远无法让它发挥作用。到目前为止,这是我尝试过的:

hm=sns.clustermap(data=pltdf.iloc()[:,1:14],
              standard_scale=0,
               yticklabels=pltdf['uniprot_sym'])
hm.set_xticklabels(rotation=30)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-87-05bb29d461e2> in <module>
      2               standard_scale=0,
      3                yticklabels=pltdf['uniprot_sym'])
----> 4 hm.set_xticklabels(rotation=30)
      5 

AttributeError: 'ClusterGrid' object has no attribute 'set_xticklabels'

还有这个

hm=sns.clustermap(data=pltdf.iloc()[:,1:14],
              standard_scale=0,
               yticklabels=pltdf['uniprot_sym'])
for ax in hm.axes.flat:
    ax.tick_params("x", labelrotation=45)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-86-d96774d92376> in <module>
      2               standard_scale=0,
      3                yticklabels=pltdf['uniprot_sym'])
----> 4 for ax in hm.axes.flat:
      5     ax.tick_params("x", labelrotation=45)

AttributeError: 'ClusterGrid' object has no attribute 'axes'

都输出 this

【问题讨论】:

  • 我使用的是 0.11.0,并更新到 0.11.1,但还是一样。不过,下面的答案确实有效。

标签: python seaborn


【解决方案1】:
hm=sns.clustermap(data=pltdf.iloc()[:,1:14],
                  standard_scale=0,
                  yticklabels=pltdf['uniprot_sym'])
plt.setp(hm.ax_heatmap.get_xticklabels(), rotation=30) 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-07
    • 1970-01-01
    • 1970-01-01
    • 2017-12-10
    • 2021-04-10
    • 1970-01-01
    • 2021-01-01
    • 2014-12-19
    相关资源
    最近更新 更多