简体   繁体   中英

Change the font size in a seaborn corrplot

My question is how to change the size of font in seaborn using correlation matrix I don't know why somehow the font is too large for me 看到打击

if you already have the correlation values in your data, you can use a heatmap and set up the size with "annot_kws", for example here setting it to 8.

sns.heatmap(data, vmin=data.values.min(), vmax=1, square=True, 
        linewidths=0.1, annot=True, annot_kws={"size":8})

and it would look like this:

在此输入图像描述

Regrettably I don't think that's configurable, but what I would recommend is just to make the figure larger eg

f, ax = plt.subplots(figsize=(10, 10))
sns.corrplot(df, ax=ax)

If that's not an option and you're primarily interested in the heatmap (not the numerical values), you could do

sns.corrplot(df, annot=False, sig_stars=False, diag_names=False)

如果您正在使用set_context,则可以添加字体缩放参数以及绘图的大小。

sns.set_context("poster",font_scale=.7)

我相信你可以使用set方法,修改font scale参数。

sns.set(font_scale=0.5)

i did this at this works quite well.

enlarged the fig size to able to read it properly

 sns.set(style="white")
f, ax = plt.subplots(figsize=(20, 20))
sns.heatmap(bos.corr(),annot=True,annot_kws={"size":15})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM