简体   繁体   English

更改seaborn corrplot中的字体大小

[英]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 我的问题是如何使用相关矩阵更改seaborn中的字体大小我不知道为什么字体对我来说太大了 看到打击

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. 如果您的数据中已经有相关值,则可以使用热图并使用“annot_kws”设置大小,例如在此处将其设置为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})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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