Sometimes I want to create and save a large number of plots, and it would be very convenient to be able to create and save them on disk without first displaying them on the screen. Is there a way to do this?
Thanks for any suggestions.
Richard Stanton
Look at matplotlibs savefig function. You would call savefig then plt.clear or whatever the clear function is. Sorry responding from phone
--
Dear Richard,
Il giorno 19/gen/2013 09:07, "Richard Stanton" <sta...@haas.berkeley.edu> ha scritto:
>
> Yaroslav Halchenko <yarik...@gmail.com> Jan 17 10:59PM -0500
>
> > I guess should be as with any module using matplotlib -- just set
> > backend to non-interactive one (e.g. Agg) first and then use savefig ;)
> > see
> > http://matplotlib.org/faq/howto_faq.html#generate-images-without-having-a-window-appear
>
> Thanks very much for the suggestion. The problem is that I'm trying to do this in an IPython notebook, and whenever I execute a plot command, the graph immediately appears on the screen. I can save it as well, using savefig, but it would be much faster if it wasn't displayed at all. I tried following the advice given in the link above, but when I try to execute the command
>
> matplotlib.use('Agg'),
>
> even right at the beginning of the notebook, I get the warning
>
> UserWarning: This call to matplotlib.use() has no effect
> because the the backend has already been chosen;
Import matplotlib explicitly ... Do not use --pylab when starting ipython notebook.
Im this way you should be able to fix the matplotlib backend as you wish.
HTH,
Eraldo