OO inteface question.

Hi all,

There has been some recent discussion about perhaps improving the OO interface. So Here's a question:

How do I save an AGG figure with the OO interface?

For example:
>>> fig = pylab.figure()
>>> ax = fig.add_subplot(1,1,1)
>>> ax.plot(range(10), pylab.sin(range(10)))

Now how do I save it as a PNG? I can do:

>>> pylab.savefig("test.png")

But then that is the interface I'm trying to get away from.

Looking at the docs, it looks like the agg back-end should have:
>>> fig.print_figure("Test.png")
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
AttributeError: Figure instance has no attribute 'print_figure'

But no such luck.

Another option would be:

>>> fig.savefig

But that's not there either.

Thanks,
-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

Pressing "send" too soon...

To partially answer my own question, I looked in matplotlib.pylab.py, and found:

manager = get_current_fig_manager()
manager.canvas.print_figure(*args, **kwargs)

However, I can't see how to get the canvas from a figure instance. This looks like one place the OO interface could be improved.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...