|
From: John H. <jd...@gm...> - 2009-02-10 14:05:45
|
On Tue, Feb 10, 2009 at 7:55 AM, Gerry Steele <ger...@gm...> wrote:
> Thanks Michael ,
>
> I had somehow put myself under the impression i was using he OO
> version of the api but it is much more clear now. Memory issues now
> look better.
There is room for confusion. A common usage pattern, one I often use
myself, is to use pyplot for figure creation, closing and showing
only, and to use the OO API for everything else. To whit:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1,2,3])
ax.set_xlabel('hi')
plt.show()
this contrasts with the pure pyplot approach, which uses the pyplot
state machine for everything (figure/axes creation, current axes, etc)
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.xlabel('hi')
plt.show()
and both are different from the pure OO approach in which you manually
create the figure canvas etc
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
fig = Figure()
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111)
ax.plot([1,2,3])
ax.set_xlabel('hi')
Note that in the 3rd example, all the code is the same as the first
example, except the figure/canvas creation, which is why one might
call it "OO pyplot"
Eric has summarized some additional information about the different
usage modes here
http://matplotlib.sourceforge.net/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related
JDH
|