Seborn,更改色条的字体大小 [英] Seaborn, change font size of the colorbar

查看:24
本文介绍了Seborn,更改色条的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改热图颜色条的字体大小。

以下是我的代码:

import seaborn as sns
import matplotlib.pyplot as plt
from numpy import arange
x = arange(25).reshape(5, 5)
cmap = sns.diverging_palette(220, 20, sep=20, as_cmap=True)
ax = sns.heatmap(x, cmap=cmap)
plt.show()

我可以使用plt.tick_params(axis='both', labelsize=20)更改刻度标签。但是,颜色栏字体大小不会更改。 有办法做到这一点吗?

推荐答案

您可以使用seaborn.set()方法更改字体比例,将font_scale参数设置为所需的比例,有关详细信息,请参阅海运documentation

例如,比例为3的绘图:

import seaborn as sns
import matplotlib.pyplot as plt
from numpy import arange
# here set the scale by 3
sns.set(font_scale=3)
x = arange(25).reshape(5, 5)
cmap = sns.diverging_palette(220, 20, sep=20, as_cmap=True)
ax = sns.heatmap(x, cmap=cmap)
plt.show()

这篇关于Seborn,更改色条的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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