[Numpy-discussion] is there any alternative to savefig?

Dag Sverre Seljebotn dagss at student.matnat.uio.no
Thu Jan 28 08:00:25 EST 2010


Robert Kiwanuka wrote:
> Hi all,
>
> I wonder if anyone knows any alternative function in pylab (or
> otherwise) that could be used to save an image. My problem is as
> follows:
>
> ---------------
> from pylab import *
> ...
>
> figure(1)
> fig1 = gca()
> figure(2)
> fig2 = gca()
> figure(3)
> fig3 = gca()
You should not use the pylab interface for stuff like this. This is much 
easier if you get rid of the notion of "current plot".

from matplotlib import pyplot as plt

fig1 = plt.figure()
ax1 = fig1.add_subplot(111)

ax1.plot_something...

fig1.savefig(...)

Etc., see matplotlib docs.

Dag Sverre



More information about the NumPy-Discussion mailing list