<div dir="ltr"><div>No need to switch backends, just use this idiom:<br><br>from matplotlib.figure import Figure<br>from matplotlib.backends.backend_agg import FigureCanvasAgg<br><br>fig = Figure()<br><br></div>... # use the figure as you like<br><div><br>canvas = FigureCanvasAgg(fig)<br>fig.set_canvas(canvas)  #not sure this line is strictly necessary<br></div><div>fig.savefig('filename')<br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 8, 2014 at 8:19 AM, Tiago Antao <span dir="ltr"><<a href="mailto:tra@popgen.net" target="_blank">tra@popgen.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have developing some notebooks to teach population genetics, and in<br>
order to spice-up some content for students I would like to generate a<br>
few animations in run-time (from PCA changes over time - this is faster<br>
than it seems). For that I need to generate a few matplotlib figures<br>
'off-line' and then generate an animation with some extra images (i.e.,<br>
I do not want the figures showing on the notebook: I will collect them<br>
as PNGs and generate an MP4 - I do not want want to use<br>
matplotlib.animation, BTW).<br>
<br>
I was wondering if there is a safe way to switch backends on server<br>
code (e.g. to Agg and them back to whatever is the default)? I have a<br>
look at the ipython source, and I am a bit afraid of potential side<br>
effects of a backend change.<br>
<br>
Thanks,<br>
Tiago<br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</blockquote></div><br></div>