On 09/01/2011 05:37 AM, CompBio wrote:
>
> I'm trying to get a script to work in batch mode to produce a large number of
> plots. I've got the following sequence of imports in a matplotlib Python
> script:
Is the script being run standalone, from a shell, and are the following
the very first imports?
>
> import matplotlib, os, sys
> ...
> if file_ext == 'png' :
> sys.stderr.write('Using PNG output format\n')
> matplotlib.use('agg')
> elif file_ext == 'pdf' :
> sys.stderr.write('Using PDF output format\n')
> matplotlib.use('PDF')
As Ben notes, you don't need the above logic to choose between agg and
pdf; but you are correct in choosing a non-interactive backend before
any import of pylab or pyplot. That should be enough to prevent any
subsequent attempt to open a display.
I'll bet the problem is that when the code above is run, file_ext is
neither 'png' nor 'pdf', so matplotlib.use is not being executed.
>
> from pylab import *
>
And at this point pylab is simply setting the default (interactive) backend.
> ... remainder of plotting code ...
>
> At first this appeared to work without any problems. I could kick off a job
> in background, log off the machine and return later when all the graphs had
> been produced.
>
> Now I get this RuntimeError exception. Is there anything else I need to do
> to convince matplotlib that it doesn't need my local display?
No--you just have to make sure that a non-interactive backend is getting
set before the first pylab or pyplot import.
Eric
>
> thanks!
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users