I have a script that uses matplotlib to plot graphs both displayed as a GUI and as PDF documents. The script may need to be run from remote terminals without X11-passthrough so they way I would like it to work is to use the default backend if X is available and, otherwise, fall back to using the Agg backend. How can I do this?
I've been trying to catch a RuntimeError and then retry with a different backend but part of matplotlib remains loaded and won't let me change backend: try: import matplotlib.pyplot as plt except RuntimeError: # retry import but without GUI capability import matplotlib plt.use('Agg') import matplotlib.pyplot as plt Has anyone managed this? Many thanks. Alex ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users