sending plot output to a bitmap widget

Hi, Is there a way to get the output of a plot (the

    > bitmap) and assign it to a bitmap object such as wxBitmap
    > or wxImage? I know how to do this by saving the figure
    > and loading it to wxBitmap. But there must be a way to do
    > it directly. Does anyone know how to do this?

Using the OO FigureCanvasWxAgg API, which I think you are using, you
already have the canvas instance. The call to canvas.draw() sets the
bitmap instance, which you can access as canvas.bitmap. So after any
draw command canvas.bitmap is updated.

You can take a look at
matplotlib.backends.backend_wxagg.FigureCanvasWxAgg.draw to see how
the backend is using agg to render, create a wxImage and wxBitmap.
You can either use the result of these calls (canvas.bitmap) or just
make them yourself in another part of your code.

JDH

    > Hi, Is there a way to get the output of a plot (the
    > bitmap) and assign it to a bitmap object such as wxBitmap
    > or wxImage? I know how to do this by saving the figure
    > and loading it to wxBitmap. But there must be a way to do
    > it directly. Does anyone know how to do this?

Using the OO FigureCanvasWxAgg API, which I think you are using, you
already have the canvas instance. The call to canvas.draw() sets the
bitmap instance, which you can access as canvas.bitmap. So after any
draw command canvas.bitmap is updated.

You can take a look at
matplotlib.backends.backend_wxagg.FigureCanvasWxAgg.draw to see how
the backend is using agg to render, create a wxImage and wxBitmap.
You can either use the result of these calls (canvas.bitmap) or just
make them yourself in another part of your code.

JDH

But it does make sense to have a general function to read out an
AGG rendered buffer to a Numeric/numarray array doesn't it? Seems
like another good thing to add to the list (unless one can do
that already, I forget the details of using AGG by itself).

Perry