Best way to save plots as images?

23 views
Skip to first unread message

Justyn

unread,
Nov 28, 2007, 2:31:43 PM11/28/07
to Reinteract
I'm pretty new to...well, all of this.

I tried to use the savefig function of pylab to save plots I'd drawn
in reinteract. However, if I import * from pylab I can no longer plot
graphs (I get something like "<matplotlib.lines.Line2D instance
at...>")

Any pointers for a complete noob?

Thanks.

Owen Taylor

unread,
Nov 28, 2007, 9:08:33 PM11/28/07
to reint...@googlegroups.com

I take it that you did something like:

from replot import plot
from pylab import *

Then what you'll get for 'plot' is the pylab command, which won't work
in reinteract, instead of the reinteract plot command from replot. Any
of the obvious approaches should work:

* Simply switch the order of the two lines above
* change the first to 'from replot import plot as replot', then use
replot() instead of plot()
* change the second to 'import pylab as p' then use p.savefig()
rather than savefig()'

You can make your own variants. However, once you get access to
'savefig()', it probably won't do what you want, since it will save
the figure in the implicit pylab drawing state, rather than the
PlotResult returned by replot's plot().

What I did for the replay.play() command, since I needed to save a
sound, was add a right-click menu option to "Save", and I think that
would be a reasonable approach here as well... it shouldn't be a big
task to implement that if you or someone else wants to take a stab at
it. You might want to file an ticket on www.reinteract.org.

- Owen

Justyn

unread,
Dec 3, 2007, 10:27:21 AM12/3/07
to Reinteract
Just updated my local git repo...thanks for adding this feature, it is
fantastic.

On Nov 29, 2:08 am, "Owen Taylor" <owtay...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages