【问题标题】:How to adjust cbar label position in sns.clustermap?如何调整 sns.clustermap 中的 cbar 标签位置?
【发布时间】:2020-02-15 17:56:19
【问题描述】:

我正在绘制一个 seaborn clustermap,但在定位颜色条标签时遇到了问题。这是我的代码:

heatmap_plot = sns.clustermap(table, method=method, metric=metric, 
                                  row_colors=row_colors,
                                  col_cluster=col_cluster, row_cluster=row_cluster,
                                  cmap=color_scheme,
                                  xticklabels=True, yticklabels=True,
                                  # linewidths=1,
                                  cbar_kws={'label': cbar_label})

plt.setp(heatmap_plot.cax.yaxis.get_label(), rotation=270)

当我想旋转 cbar 标签文本时,它与刻度重叠,我不知道如何重新定位它。有谁知道如何解决这个问题?

【问题讨论】:

    标签: seaborn heatmap


    【解决方案1】:

    您可以在 sns.clustermap 主调用中省略颜色条标签,然后执行

    heatmap_plot.cax.set_title("my cbar label")
    

    【讨论】:

    • 感谢您的解决方案...到目前为止,我手动设置了坐标,效果也很好 - heatmap_plot.cax.yaxis.set_label_coords(cbar.x0 + cbar.width + 2.7 , hm.y0 + height/2)
    • @Marija 如何访问 cbar?
    猜你喜欢
    • 2022-08-19
    • 1970-01-01
    • 2010-11-21
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多