【问题标题】:Seaborn: How to increase the font size of the labels on the axes?Seaborn:如何增加轴上标签的字体大小?
【发布时间】:2021-03-11 11:21:52
【问题描述】:

这是我绘制热图的方法:

sns.heatmap(table, annot=True, fmt='g', annot_kws={'size':24})

问题是,size 仅设置热图中数字的字体大小。我应该在annot_kws 中使用哪个参数来设置轴上标签的字体大小?

谢谢

【问题讨论】:

    标签: python-3.x matplotlib seaborn


    【解决方案1】:

    您不能直接在对heatmap 的调用中更改它们,但您可以指示matplotlib 更改字体大小in plt.rcParams directly 或使用context manager

    uniform_data = np.random.rand(10, 12)
    plt.figure()
    with plt.style.context({'axes.labelsize':24,
                            'xtick.labelsize':8,
                            'ytick.labelsize':16}):
        ax = sns.heatmap(uniform_data, annot=True, fmt='.1f', annot_kws={'size':6})
        ax.set_xlabel('x label')
    

    【讨论】:

      猜你喜欢
      • 2017-09-25
      • 1970-01-01
      • 2012-07-05
      • 2021-01-07
      • 2016-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多