Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plt.figure(figsize=(10,20)) is not working

I am using matplotlib.pyplot to plot a histogram and i want to increase the size of the plot. The code to plot is:

plt.hist(x)
plt.xlabel("Months")
plt.ylabel("Donated")
plt.figure(figsize=(6,4))
plt.show()

But plt.figure(..) is not having any affect on the size of the the graph. I am using Spyder IDE.

like image 351
sak Avatar asked Dec 29 '25 14:12

sak


2 Answers

You want to define your figure space prior to creating the plot information.

plt.figure(figsize=(6,4))
plt.hist(x)
plt.xlabel("Months")
plt.ylabel("Donated")
plt.show()

This will define your figure then plot information in that space, otherwise Matplotlib will use defaults.

like image 147
Bryce Wayne Avatar answered Jan 01 '26 03:01

Bryce Wayne


Just put it at the top:

plt.figure(figsize=(10,20))
plt.hist(x)
plt.xlabel("Months")
plt.ylabel("Donated")
plt.show()
like image 24
Yash Thenuan Avatar answered Jan 01 '26 04:01

Yash Thenuan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!