简体   繁体   English

如何更改seaborn pairplot中轴标签和值的大小

[英]How to change size of axis labels and values in seaborn pairsplot

I've created a pairplot in seaborn using the following code:我使用以下代码在 seaborn 中创建了一个pairplot:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

mtcars = pd.read_csv("https://raw.githubusercontent.com/focods/WonderfulML/master/data/mtcars.csv")
sns.pairplot(mtcars, kind='reg', diag_kind='hist')

and get this plot:并得到这个情节:

在此处输入图片说明

The font is tiny and I'm trying to figure out how to increase the size.字体很小,我想弄清楚如何增加大小。 I see in the documentation a parameter that might be what I'm looking for: plot_kws which is a dictionary, but how do I figure out the available keys and what they do?我在文档中看到一个可能是我正在寻找的参数: plot_kws这是一个字典,但是我如何找出可用的键以及它们的作用?

So I have two questions.所以我有两个问题。 First, is how to read the documentation so that I can figure out what the keys are for this dictionary.首先,是如何阅读文档,以便我可以弄清楚这本词典的键是什么。 Second, is how to increase the font size of the y-axis labels for this plot.其次,是如何增加此图的 y 轴标签的字体大小。

Turns out that to change the size of x and y axis labels, I needed to call set_context and pass a dictionary to the rc parameter.事实证明,要更改 x 和 y 轴标签的大小,我需要调用set_context并将字典传递给rc参数。 When I added this line just above the call to pairplot :当我在调用pairplot 的正上方添加这一行时

sns.set_context("paper", rc={"axes.labelsize":36})

I get this plot:我得到这个情节:

在此处输入图片说明

which is an improvement (if you look closely), but am now trying to figure out how to increase the size of the tick labels.这是一个改进(如果你仔细观察),但现在我正试图弄清楚如何增加刻度标签的大小。

Resize the graph with all the parameters.使用所有参数调整图形的大小。

seabornInstance.set_context("paper", rc={"axes.labelsize":20})
seabornInstance.set_context("talk", font_scale=1.4)
xpl=seabornInstance.pairplot(mtcars, kind='reg', diag_kind='hist',height=7, aspect=1)

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

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