I'm unable to resize the graph in my matplotlib scatter plot. I have included plt.figure(figsize=(20,20))
but it doesn't affect the size.
Here is the current plot output.
plt.scatter(x['so2_x'],x['state'],alpha=0.5,c=x['so2_x'],s=x['so2_x'])
plt.title("so2@2011 vs state")
plt.figure(figsize=(20,20))
plt.show
This line isn't doing what you think it is.
plt.figure(figsize=(20,20))
Instead of adjusting the size of the existing plot, it's creating a new figure with a size of 20x20. Simply move the above line before the call to scatter and things will work as you want.
plt.figure(figsize=(20,20))
plt.scatter(x['so2_x'],x['state'],alpha=0.5,c=x['so2_x'],s=x['so2_x'])
plt.title("so2@2011 vs state")
plt.show()
Another alternative is to change the size after the call to scatter implicitly creates the figure object using gcf() to return the current figure handle.
plt.scatter(x['so2_x'],x['state'],alpha=0.5,c=x['so2_x'],s=x['so2_x'])
plt.title("so2@2011 vs state")
plt.gcf().set_size_inches((20, 20))
plt.show()
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.