I would like to adjust the size of this distribution plot in 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...
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). If you do a dir(g)
you would see that it has no fig
method/attribute. But it has a figure
attribute. 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:
plt.figure(figsize=(30,10)) # Use this line
# plt.gcf().subplots_adjust(left = 0.3)
g = sns.distplot(df['data'])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.