6

I've tried as many solutions as I could find on here, but I'm not having much luck on this. I'm not sure if it's because some of my settings, but I am unable to reshape my Seaborn countplot. Here's my code where I plot the figure:

sns.set_style('whitegrid')
sns.set(font_scale=1.3)
sns.countplot(x=df['QuarterYear'], hue=df['Modifier'])
ax = plt.gca()

for p in ax.patches:
    ax.text(p.get_x() + p.get_width()/2., p.get_height(), '%d' % int(p.get_height()), 
            fontsize=12, color='black', ha='center', va='bottom')

plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)

I am also editing the legend and labeling my countplot columns in the same block of code.

I am using Jupyter Notebook %inline. If anyone could explain what I am missing, that would be great. I've tried many, many variations of these solutions, to no avail.

How do I change the figure size for a seaborn plot?

How to make seaborn.heatmap larger (normal size)?

How do I change the plot size of a regplot in Seaborn?

Any help would be appreciated. Thank you for your time!

Angus Gray
  • 393
  • 2
  • 5
  • 19

1 Answers1

6

Have you tried:

fig = plt.gcf()
fig.set_size_inches( 16, 10)
Learning is a mess
  • 7,479
  • 7
  • 35
  • 71
  • That seemed to do it. I think I'm misunderstanding the difference between plt.gcf() vs plt.gca() Would you happen to know the difference? – Angus Gray Jul 24 '18 at 15:59
  • 1
    `gcf` returns a `Figure`, a canvas to draw on it. `gca` returns an `Axes`, to make a plot. Very basically, in matplotlib, a figure contains one or more axes, see https://matplotlib.org/users/artists.html for more detail. In your case you need to resize the whole figure to have a larger display. – Learning is a mess Jul 24 '18 at 16:02
  • That is a great explanation. Thank you very much! – Angus Gray Jul 24 '18 at 16:04