Hello matplotlib users, I just recently started using the matplot library for generating simple graphs instead of using R. The problem i'm experiencing are the following. On my work station i had to enable x11 forwarding to be able to run a script generating plots on a server . The problem now is that my own computer is a mac and normally when i use the x11 app to connect to a server x forwarding is suited to run all script that use a x11 window. when i start a development server ( in Django ) from the my linux computer it works but from apple it doesn't In this case i get a error saying that i miss the DISPLAY variable. I talked to our sys administrator because i was thinking how it would respond when i put the version in production in this case it would be behind apache instead of a development server that i manually start in Django. He told me that that could be a problem because apache doesn't connects to any x11 display. Does anyone had some experience with using apache and matplot lib together, if so could you share the experiences you had installing everything. I'd like to know before i continue developing these features of the application. Any help would be greatly appreciated. Regards, Richard Mendes -- View this message in context: http://www.nabble.com/matplotlib-x11-usage-tp17536252p17536252.html Sent from the matplotlib - users mailing list archive at Nabble.com.
On Thu, May 29, 2008 at 9:40 AM, cyclopsvs <men...@gm...> wrote: > Does anyone had some experience with using apache and matplot lib together, > if so could you share the experiences you had installing everything. > > I'd like to know before i continue developing these features of the > application. matplotlib renders to a number of different targets, eg user interfaces, PNG, or postscript. The user interfaces require an x11 connection, but the image generation backends do not. Thjese are the ones you will want to use with apache, django, etc. What you need to do is set your default backend to "Agg" in your matplotlibrc file. This file resides in site-packages/matplotlib/mpl-data and can be moved into either HOME/..matplotlib or your working directory (eg where your image generating code lives). Once this is done mpl will generate PNGs w/o an X11 connection. http://www.scipy.org/Cookbook/Matplotlib/Django has some information on using mpl with django, but it is bit out of date because you no longer need PIL to save to a file handle. mpl can now save PNG directly to a file handle
cyclopsvs wrote: > Hello matplotlib users, > > I just recently started using the matplot library for generating simple > graphs instead of using R. The problem i'm experiencing are the following. > > On my work station i had to enable x11 forwarding to be able to run a script > generating plots on a server . The problem now is that my own computer is a > mac and normally when i use the x11 app to connect to a server x forwarding > is suited to run all script that use a x11 window. If you don't need interactive plots, you might consider doing it the old-fashioned way: saving the plots as png files in batch mode and displaying with firefox. import matplotlib matplotlib.use('Agg') #non-interacive back-end import matplotlib.pyplot as plt .... plt.savefig('/home/me/public_html/plots/thefile.png',dpi=100) We've automated this so the python script makes the plots, builds an image gallery with thumbnails and then copies the plots off our cluster (which doesn't mount the web server directory) and onto the web server using rsync. For example http://clouds.eos.ubc.ca/~phil/savefigs/E/ -- Phil