Is there any way of getting around this? In
> particular, when I am running python remotely on the
> terminal, it will not let me use matplotlib since
> access to the screen is required. However, I would
> like to be able to generate plots to file (remotely)
> without ever showing them on the screen. Is there
> something I need to set in order to satisfy this?
Three ways that come to mind:
1) use the PS backend
2) use the GD backend with the install instructions in my post
3) run the Xvfb virtual X server. This works with the GTK and (in
the near future) with the WX backend. Below, in a nutshell, is
how to run a xvfb on a linux-like system -- your paths may vary.
To see if you have Xvfb installed on your system, check for
/usr/X11R6/bin/Xvfb. It came with the X tools CD on my powerbook
I have added a function to the GTK backend called show_xvfb to be
used in place of show which will just print the figures and then
quit GTK. See the attached files below for how to use xvfb with
the gtk backend. Without it, the figure will remain open waiting
to be closed since for all it knows it launched a figure and the
user is looking at it; so the gtk event loop just hangs waiting
for an event that never happens.
> export XVFB_HOME=/usr/X11R6
> $XVFB_HOME/bin/Xvfb :1 -co $XVFB_HOME/lib/X11/rgb -fp $XVFB_HOME/lib/X11/fonts/misc/,$XVFB_HOME/lib/X11/fonts/Speedo/,$XVFB_HOME/lib/X11/fonts/Type1/,$XVFB_HOME/lib/X11/fonts/75dpi/,$XVFB_HOME/lib/X11/fonts/100dpi/&
Now xvfb is running in the background on X11 port 1
> export DISPLAY=:1
> pythonw yourscript.py -dGTK
I suspect Jeremy will add some similar functionality to the WX
backend when he can.
The easiest of these three solutions is 1), since all you need for the
PS backend is Numeric. You could convert somefile.ps to somefile.png
using any of a variety of image processing tools.
The GD backend also works great for 'offline' processing, but it has a
number of dependencies.... As I noted yesterday, though, all of these
compile from source fine on OSX so it's just a matter of forging
An example script:
xvfb_demo.py (476 Bytes)
backend_gtk.py (36 KB)