Subclassing PyPlot, need some help

Andriy basilisk96 at gmail.com
Thu Aug 2 08:12:51 PDT 2007


> To me it looks like you are mixing different approaches. Either subclass
> PlotCanvas and modify only the drawing code, i.e. that part that
> actually paints the graph, frame, labels, etc. or create a custum class
> that contains an arbitrary number of PlotCanvas objects. Note that
> PlotCanvas is a wx.Panel, so you might want to put them in a sizer.
> Obviously only with the first method you will have a single DC which can
> be exported easily.
>
> Currently you're subclassing PlotCanvas and then you put additional
> PlotCanvas objects in there. I doubt that this will work.
>
> Christian

Yeah, the second approach with sizers is what I tried previously,
because it made sense at the time, but I was frustrated because it did
not have a unified DC from which I could print or save images (both of
which are features that I need). I was able to hack together a buffer
stitching function that drew all the subpanels into one, but I had no
control over its size. It did look good on screen, so I have kept it
for a while.
I like your first suggestion better.  In that case, would I have to
override the PlotCanvas._Draw() method entirely so that the resulting
drawing is sized and placed properly on the canvas, or can I still
call _Draw() with the optional dc argument, then manipulate the size
of the resulting DC so that I can draw the properly proportioned
subplot into its place on the canvas? Sorry, I am not (yet) proficient
with DC's to completely understand this yet, but I'm trying ;-)

-amv




More information about the wxpython-users mailing list