From: Engelsma, D. <D.E...@La...> - 2004-05-03 20:15:58
|
Hello -- I'm having a dickens of a time getting this to work... I believe I understand what you mean about maintaining a list of FigureCanvasAggs and using string & bitmap methods to get the figures into my wxDialog. Where I'm stuck is in plotting a histogram to a FigureCanvasAgg... I've checked out your examples, but there doesn't appear to be anything that directly uses FigureCanvasAgg. I've tried many different ways (mostly based on the embedded_in_wx.py and histogram_demo.py examples). Based on the example "histogram_demo.py" could you please give some pointers as to how to plot the histogram to a FigureCanvasAgg? I think I can handle things after that... Thanks for your assistance! Dave Engelsma Lacks Wheel Trim Systems > -----Original Message----- > From: John Hunter [mailto:jdh...@ac...] > Sent: Saturday, April 24, 2004 9:53 AM > To: Engelsma, Dave > Cc: mat...@li... > Subject: Re: [Matplotlib-users] wxList and FigureCanvasWx > > >>>>> "Engelsma," == Engelsma, Dave <D.E...@La...> writes: > > Dave> Hello - I''ve got a wxDialog where, among other > Dave> controls, I have a wxList and a > Dave> FigureCanvasWx. Depending on what single item is > Dave> selected in the wxList, the FigureCanvasWx should show > Dave> the appropriate graph. It's important that the > Dave> matplotlib-generated graph stay in the dialog along > Dave> with the other controls (I don't want to generate a > Dave> separate frame for the graph). > > I'm not a wx guru, so this may not be the best way, but it I think it > is a pretty good way. Instead of putting a FigureCanvasWX in your, > use a wxPanel instead. Maintain a list of FigureCanvasAgg and use > them to draw your figures. Transfer these to the wxPanel using string > and bitmap methods. This is effectively what wxagg does. The main > difference is that you will have one canvas and a list of > FigureCanvasAggs. > > You can get the width and height of the figure you need to draw with > > > > Suppose agg below is an FigureCanvasAgg instance > > agg.draw() > s = agg.tostring_rgb() > l,b,w,h = agg.figure.get_window_extent().get_bounds() > image = wxEmptyImage( w,h ) > image.SetData(s) > bitmap = image.ConvertToBitmap() > > You can then transfer the bitmap to the wxpanel. If you want to do > all the 'draw' calls upfront so you don't have to repeatedly draw if > the user selects one figure, then another, then the original, that > will be fine. > > Agg is a pretty fast renderer, which may more than make up for the > performance hit of having to go through the string->bitmap->canvas. > > Let me know how it goes. > > JDH |