I wrote a bunch of graph scripts for creating on-the-fly line plots with django. Since I'm running the site on a low memory VPS, I need to run apache in multi-threaded mode, which means all my code needs to be thread-safe. I was using Pyplot a lot, which is not thread-safe. A solution I came up with which worked pretty well was to replace this:
import matplotlib.pyplot as plt self.fig = plt.figure(figsize=(3.5, 2.5),) with this: from matplotlib.figure import Figure self.fig = Figure(figsize=(3.5, 2.5),) It worked like a charm on all my graphs. I have a few maps that I created with Basemap which this method does not seem to work on. My code works perfectly fine with the first snippet posted above, but if I change it to the snippet below, I get this error: File "/srv/proj/maps/states.py" in as_response 40. return plot_png2(self.plot).__call__() File "/srv/proj/graphs/image_formats.py" in __call__ 50. edgecolor="white") File "/usr/lib/pymodules/python2.6/matplotlib/figure.py" in savefig 1033. self.canvas.print_figure(*args, **kwargs) the second item in the traceback is this line: fig.savefig(response, format=self.extension, bbox_inches="tight", pad_inches=.05, edgecolor="white") Any ideas on whats going on here? -- View this message in context: http://old.nabble.com/matplotlib.figure-and-basemap-tp27477116p27477116.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users