how to change the dimensions of a histogram depicted by plt.hist() as figsize is not an argument

Viewed 38072

I am trying to plot a histogram with a series using numpy array.

n,bins,patch = plt.hist(ser,bins=10, color='green', alpha=0.8, label='Value', edgecolor='orange', linewidth=2)
plt.legend()
plt.ylabel('No of bags', size='x-large')
plt.xlabel('Money in US $', size= 'x-large')

IT is working well but the size is spo small. I tried using olt.hist(figsize=(8,8)) but it throws error as expected.

How can I increase the size of my histogram figure?

2 Answers
plt.figure(figsize=(8,8)) #change your figure size as per your desire here
n,bins,patch = plt.hist(ser,bins=10, color='green', alpha=0.8, label='Value', edgecolor='orange', linewidth=2)
....
....

To change the background color and the border color:

plt.figure(figsize=(8,8),facecolor='red',edgecolor='blue')

I tried doing this though. Adding these 2 lines before my question code

fig=plt.figure(figsize=(8,6))
his=fig.add_axes([0,0,1,1])

``
Related