简体   繁体   中英

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?

Use another backend, for example Agg or SVG:

import matplotlib
matplotlib.use('Agg')
...
matplotlib.savefig('out.png')

Yes, after creating the plots etc., instead of calling

pylab.show()

call

pylab.savefig('filename.XXX')

where XXX is one of the common image extensions (png, jpg...)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM