问题描述
from pylab import rcParams
rcParams['figure.figsize'] = (10, 10)
这适用于直方图,但不适用于因子图.sns.factorplot (.....) 仍然显示默认大小.
This works fine for histogram plots but not for factor plots.sns.factorplot (.....) still shows the default size.
sns.factorplot('Pclass','Survived',hue='person',data = titanic_df,size = 6,aspect =1)
我每次都必须指定大小和方面.
I have to specify size,aspect everytime.
请在全球范围内提出对他们都有效的建议.
Please suggest something that works for both of them globally.
推荐答案
无法通过rcParams更改 factorplot
的图形大小.
It's not possible to change the figure size of a factorplot
via rcParams.
图形尺寸为在FacetGrid类内部进行了硬编码为
figsize = (ncol * size * aspect, nrow * size)
然后使用此 figsize
创建一个新图形.
A new figure is then created using this figsize
.
这使得无法通过调用 factorplot
的函数中的参数以外的其他方式更改图形大小.这也使得首先创建一个具有其他参数的图形并将因子图绘制到该图形上也是不可能的.但是,对于具有单轴的因子图的解决方法,请参阅 @MartinEvans 的回答.
This makes it impossible to change the figure size by other means than the argument in the function call to factorplot
. It makes it also impossible to first create a figure with other parameters and plot the factorplot to this figure. However, for a workaround in case of a factorplot with a single axes see @MartinEvans' answer.
seaborn 在这里争论的作者这是因为因子图需要完全控制该图.
The author of seaborn argues here that this is because a factorplot would need to have full control over the figure.
虽然可能会问是否需要这样做,但除了(a)在 GitHub站点和/或编写自己的包装器-鉴于seaborn以及matplotlib是开源的,这并不难.
While one may question whether this needs to be the case, there is nothing you can do about it, other than (a) adding a feature request at the GitHub site and/or write your own wrapper - which wouldn't be too difficult, given that seaborn as well as matplotlib are open source.
这篇关于以一种常见的方式改变 seaborn 图和 matplotlib 库图的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!