Seaborn:如何增加轴上标签的字体大小? [英] Seaborn: How to increase the font size of the labels on the axes?

查看:118
本文介绍了Seaborn:如何增加轴上标签的字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我绘制热图的方法:

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

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

谢谢

解决方案

您不能直接在对 heatmap 的调用中更改这些字体,但是可以指示matplotlib更改字体大小

Here's how I plot the heat map:

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

The thing is, size set only the font size of the numbers inside the heatmap. Which parameter I should use in annot_kws to set the font size of the labels on the axes?

Thanks

解决方案

You cannot change those directly in the call to heatmap, but you can instruct matplotlib to change the font size either in plt.rcParams directly, or using a 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')

这篇关于Seaborn:如何增加轴上标签的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆