2016-05-15 328 views
0

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

下面是我的代码:

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)改变刻度标记。但是,色条字体大小不会更改。 有没有办法做到这一点?

enter image description here

回答

2

您可以用seaborn.set()方法设置font_scale参数去你想要的规模改变字体放大,看得更在seaborn 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() 

plot with big font scale

相关问题