[wxPython-users] Re: Subclassing PyPlot, need some help
Christopher Barker
Chris.Barker at noaa.gov
Thu Aug 2 10:02:35 PDT 2007
Andriy wrote:
> 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?
The easiest option would be to create a wx.MemoryDC for each subplot,
then draw each resulting bitmap to the main DC where you want them.
However, while this would work great on screen, it wouldn't work so well
for printing, as you'd be printing bitmaps, rather than vector graphics.
It may end up looking OK, if you get the resolutions right, but it feels
kludgy.
Better options:
Maybe the best way (and the most work) would be to move to
wx.GraphicsContext, rather than DC -- then you could take advantage of
transforms to put your plots where and at what size you want them.
Easier: You can probably use a combination of:
wx.DC.SetDeviceOrigin
wx.DC.SetUserScale
setting those parameters differently, you may be able draw each subplot
where you want, all with the same DC. UserScale has issues, as DCs are
all integer based, but you may even be able to do without that. Really,
setting the Origin should be all you need to draw your subplots where
you want, as long as the Drawing code doesn't use the size of the DC to
scale and position things.
Hope that helps,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the wxpython-users
mailing list