如何在 Python Seaborn 包中更改图形的大小 [英] How to change a figure's size in Python Seaborn package
问题描述
我在使用 Seaborn(作为 sns
导入)增加绘图图形的大小时遇到问题.我正在使用 sns.pairplot
将数据框的列相互绘制出来.
I'm having trouble increasing the size of my plot figures using Seaborn (imported as sns
). I'm using sns.pairplot
to plot columns of a data frame against one another.
%matplotlib inline
plt.rcParams['figure.figsize']=10,10
columns=list(df.columns.values)
g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
用数据填充绘图就好了,但图形尺寸太小.
The plots populate with data just fine, but the figure size is too small.
我以为 plot.rCParams['figure.figsize']
会控制图形的大小,但它似乎没有生效.我尝试了一些来自在线论坛的不同建议,但似乎没有任何效果.
I thought plot.rCParams['figure.figsize']
would control how large the figure is, but it doesn't seem to take effect. I've tried a few different suggestions from online boards, but nothing seems to work.
推荐答案
sns.pairplot返回底层 PairGrid 实例以进行进一步调整"...例如改变图形大小:
sns.pairplot "Returns the underlying PairGrid instance for further tweaking" ...for instance changing the figure size:
g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
g.fig.set_size_inches(15,15)
这篇关于如何在 Python Seaborn 包中更改图形的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!