I'm working remotely on a machine that's pretty restrictive. I can't install any software, and it won't accept my X11 session, so I have no display. The machine currently has pylab installed, and I'd like to use it to plot something and then save it for viewing on another computer. However, it seems there's no way to even create a plot without a display. Am I missing something?
Don't show the plot show()” also written as “plt. show()” is the command responsible for showing the plot. If you want the figure to NOT show, then simply skip this step. By this way, the plot is generated, saved and closed.
Simply call plt. close() at the end of each plot instead of plt. show() and they won't be displayed.
Using plt. show() in Matplotlib mode is not required.
show() is a must. Matplotlib is used in a IPython shell or a notebook (ex: Kaggle), plt. show() is unnecessary.
Use another backend, for example Agg or SVG:
import matplotlib
matplotlib.use('Agg')
...
matplotlib.savefig('out.png')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With