简体   繁体   English

如何在seaborn pairplot中仅更改x或y标签的字体大小?

[英]How to change fontsize of only x or y labels in seaborn pairplot?

I use a sample code to make a pairplot by seaborn:我使用示例代码通过 seaborn 制作配对图:

import seaborn as sns
penguins = sns.load_dataset("penguins")
sns.pairplot(penguins, corner=True)

I would like to change the font size of x and y labels only (not xticks / yticks).我只想更改 x 和 y 标签的字体大小(不是 xticks / yticks)。 I am aware of sns.set(font_scale=k) , but it affects all texts (xy labels, xy ticks).我知道sns.set(font_scale=k) ,但它会影响所有文本(xy 标签、xy 刻度)。 However, I want to change font size of only xy lables.但是,我只想更改 xy 标签的字体大小。

If you have any idea.如果你有任何想法。 please let me know.请让我知道。

You can use sns.set_context like below:您可以使用sns.set_context如下所示:

import seaborn as sns

penguins = sns.load_dataset("penguins")
sns.pairplot(penguins, corner=True)
sns.set_context(rc={"axes.labelsize":20})

Output:输出:

在此处输入图片说明

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

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