I\'m studying matplotlib and don\'t know how to just save the graph and not print it on the screen.
So I\'ve done some research on the Internet, many answers said
plt.plot(x,y)
plt.savefig('path/figure_filename.jpg',dpi=300)
The answer to your original question is simple.
If you don't want to show the graph on screen, just don't use plt.show()
So what you've gotta do is simply:
import matplotlib.pylab as plt
plt.plot(x,y) #whatever the x, y data be
#plt.show() """Important: either comment this line or delete it"""
plt.savefig('path/where/you/want/to/save/filename.ext')
#'filename' is either a new file or an already existing one which will get overwritten at the time of execution. 'ext' can be any valid image format including jpg, png, pdf, etc.
You can try to switch the backend. Apparently Spyder loads matplotlib before you do, and use
has no effect. This may be helpful:
How to switch backends in matplotlib / Python