Hm, 2.5.3.1. I know it's time to update my system, but
> this will have to wait for a while. I need to
> coordinate several modules / versions.
The figsize parameter is being respected for me on OSX 10.3 with
matplotlib 0.80 and wx 2.5.4.1.
Not sure if it is a matplotlib version or wxpythnon version that is
causing your problems. I looked through the CHANGELOG to see if there
were any obvious changes between 0.71 and 0.80 that indicated a bugfix
for wx figure sizing, but didn't see any. You might also check the
commit notes for backend_wx or backend_wxagg.
JDH
Christian,
I don't recall seeing this behavior of absurdly small figures
and no response to figsize argement, even using wxPython 2.5.3
on Mac OS X (though, admittedly I'm using matplotlib 0.8).
The script below works fine for me, and changing the figsize
argument to Figure() does change the figure size. Does this work
for you -- you might have to change the wxversion.select() line,
or just comment it out. If this works for you, can you post a
simple, self-contained script that fails?
Cheers,
--Matt
#!/usr/bin/env python
import wxversion
wxversion.select('2.5.3-mac-ansi')
import wx
print 'using wxPython version ', wx.__version__
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure
class SimpleFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1, 'wx Matplotlib Frame')
self.figure = Figure(figsize=(5,3),dpi=96)
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvas(self, -1, self.figure)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW|wx.EXPAND)
self.SetSizer(self.sizer)
self.Fit()
class App(wx.PySimpleApp):
def OnInit(self):
frame = SimpleFrame()
frame.Show(True)
return True
app = App(0)
app.MainLoop()
···
##############
Thanks, Matt!
It took me a while to understand this: Your mini-script worked like expected. I could change the size easily. But my own program still didn't react to any change in the figsize parameter.
However, as soon as I took out the toolbar, everything was fine! There seems to be a conflict with the sizers, which I could not solve until now. I will dive into this and post an update, if I find a solution.
Cheers
Christian
···
On 29 May 2005, at 05:08, Matt Newville wrote:
Christian,
I don't recall seeing this behavior of absurdly small figures
and no response to figsize argement, even using wxPython 2.5.3
on Mac OS X (though, admittedly I'm using matplotlib 0.8).
The script below works fine for me, and changing the figsize
argument to Figure() does change the figure size. Does this work
for you -- you might have to change the wxversion.select() line,
or just comment it out. If this works for you, can you post a
simple, self-contained script that fails?
Cheers,
--Matt
Christian,
Hmm, it does sound like there might be a sizer conflict. Do you
get the tiny-figurecanvase behavior with the embedding_in_wx*.py
examples?? These have toolbars, but start off with reasonable
sizes, and respond to resizing ok for me.
--Matt
One - hopefully final - update:
As some might remember my original snippet was this:
class SAXS_wx(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,None,-1,"SPlot")
<snip>
self.fig = Figure(figsize=(5,4),dpi=100)
self.axes = self.fig.add_subplot(111)
self.canvas = FigureCanvas(self, -1, self.fig)
self.parent = self.canvas.GetParent()
self.canvas.mpl_connect('motion_notify_event',self.mouse_move)
sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer = sizer
sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW|wx.EXPAND)
self.add_splot_toolbar()
self.SetSizer(self.sizer)
self.Fit()
The problem was that changing the figsize parameter had no effect on the frame size. Changing to
self.SetSizer(self.sizer)
self.Fit()
self.add_splot_toolbar()
solved the problem, where add_splot_toolbar() - a toolbar function very much like the 2nd toolbar in the wx examples - is added only just after arranging the sizer. I was unable to arrange the toolbar with the sizer - regardless of the sizer and the layout I used. Hence the problem is definitively wx-related, possibly together with a problem in Panther's framework, since I find the old sequence of commands in the examples and the misbehaving canvas there as well.
May I suggest adding a comment in the examples for OSX users so that they are aware of a possible conflict there?
Thanks once more,
Christian