[IPython-dev] Temporarily suspending matplotlib inline backend
G Jones
glenn.caltech at gmail.com
Wed Oct 8 09:15:42 EDT 2014
No need to switch backends, just use this idiom:
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg
fig = Figure()
... # use the figure as you like
canvas = FigureCanvasAgg(fig)
fig.set_canvas(canvas) #not sure this line is strictly necessary
fig.savefig('filename')
On Wed, Oct 8, 2014 at 8:19 AM, Tiago Antao <tra at popgen.net> wrote:
> Hi,
>
> I have developing some notebooks to teach population genetics, and in
> order to spice-up some content for students I would like to generate a
> few animations in run-time (from PCA changes over time - this is faster
> than it seems). For that I need to generate a few matplotlib figures
> 'off-line' and then generate an animation with some extra images (i.e.,
> I do not want the figures showing on the notebook: I will collect them
> as PNGs and generate an MP4 - I do not want want to use
> matplotlib.animation, BTW).
>
> I was wondering if there is a safe way to switch backends on server
> code (e.g. to Agg and them back to whatever is the default)? I have a
> look at the ipython source, and I am a bit afraid of potential side
> effects of a backend change.
>
> Thanks,
> Tiago
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20141008/1831bd78/attachment.html>
More information about the IPython-dev
mailing list