Tuesday, April 05, 2011

Re: Matplotlib - an odd problem: "Your code redraws over the same graph over and over again. You need to
create a new graph each time you want to draw something new. It took me
ages (and help) to figure out how the non-global APIs in matplotlib.

Here's an example:

from matplotlib.figure import Figure
from matplotlib.axes import Axes
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas

fig = Figure(figsize=(9, 9), dpi=100)
axe = Axes(fig, (0, 0, 1.0, 1.0))
axe.pie(range(5))
fig.add_axes(axe)

canvas = FigureCanvas(fig)
canvas.set_size_request(640, 480)

fig.savefig('foo.png')"