2016-05-15 242 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

相關問題