Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to use pyplot without DISPLAY?

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?

like image 792
lemur Avatar asked May 04 '10 14:05

lemur


People also ask

How do I not show plot in matplotlib?

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.

How do I save a figure without displaying it in matplotlib?

Simply call plt. close() at the end of each plot instead of plt. show() and they won't be displayed.

Is PLT show () necessary?

Using plt. show() in Matplotlib mode is not required.

Is PLT show necessary in Jupyter?

show() is a must. Matplotlib is used in a IPython shell or a notebook (ex: Kaggle), plt. show() is unnecessary.


1 Answers

Use another backend, for example Agg or SVG:

import matplotlib
matplotlib.use('Agg')
...
matplotlib.savefig('out.png')
like image 179
wump Avatar answered Oct 17 '22 22:10

wump