[英]How to adjust size of Seaborn distribution graph
I would like to adjust the size of this distribution plot in Seaborn
.我想在
Seaborn
调整这个分布图的大小。 I tried a few ways from online tutorials and the docs but nothing seemed to actually work.我从在线教程和文档中尝试了几种方法,但似乎没有任何实际效果。 I find this really confusing as it appears different plots such as
plt
, sns
have different functions which don't seem to work interchangeably...我发现这真的很令人困惑,因为看起来不同的图,例如
plt
, sns
具有不同的功能,它们似乎不能互换工作......
My code:我的代码:
import seaborn as sns
g = sns.distplot(df['data'])
g.fig.set_figwidth(20)
g.fig.set_figheight(10)
g is an matplotlib.axes._subplots.AxesSubplot
(try type(g)
to see that). g 是一个
matplotlib.axes._subplots.AxesSubplot
(试试type(g)
看看)。 If you do a dir(g)
you would see that it has no fig
method/attribute.如果你做一个
dir(g)
你会看到它没有fig
方法/属性。 But it has a figure
attribute.但它有一个
figure
属性。 So change your code to reflect that and you would have what you need.因此,更改您的代码以反映这一点,您将拥有所需的东西。
import seaborn as sns
g = sns.distplot(df['data'])
g.figure.set_figwidth(20)
g.figure.set_figheight(10)
Thanks @Sinan Kurmus's answer, just an alternative solution:感谢@Sinan Kurmus 的回答,只是一个替代解决方案:
plt.figure(figsize=(30,10)) # Use this line
# plt.gcf().subplots_adjust(left = 0.3)
g = sns.distplot(df['data'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.