From: Kaipo Chang on 28 Apr 2010 09:13 I wrought something like client = plot.PlotCanvas(childFrame2, 2,pos=(300,400),size=(100,200), name=text1) But the plotcanvas kept filling all the childFrame. Is there a way to Really adjust the size of ploscanvas? Thanks in advance for your help. The problematic code is below: class FrameWithAButton(wx.Frame): def __init__(self, parent, id, title, list=[]): wx.Frame.__init__(self, parent, id ,title, size=(500,200)) self.data = xyList self.xList = [] self.yList = [] for (x,y) in self.data: self.xList.append(x) self.yList.append(y) panel = wx.Panel(self, -1) wx.Button(panel, 1, 'scatter', (10,10)) wx.Button(panel, 2, 'regression line with scatter', (10,40)) self.Bind(wx.EVT_BUTTON, self.on_scatter, id=1) self.Bind(wx.EVT_BUTTON, self.on_line, id=2) def on_scatter(self, event): """Plot the points in xyList. """ childFrame1 = wx.Frame(self, -1, 'scatter', size=(800,600)) client = plot.PlotCanvas(childFrame1) markers = plot.PolyMarker(self.data, legend='Zipf\'s law', colour='red', size=1) gc = plot.PlotGraphics([markers], 'Scatter', 'logr', 'logf') client.Draw(gc, xAxis=(0,9), yAxis = (0,10)) childFrame1.Show(True) def on_line(self, event): """Plot the points and draw the regression line out of xList and yList, inside a Plot Canvas panel; """ #Succeded in making the graph, but failed to set the position of PlotCanvas. #The pos=(300,400) just did not work! kaipo 2010/04/28 19:20 (meanX, meanY, betaZero, betaOne, sumYY) = cal_beta(self.xList, self.yList) childFrame2 = wx.Frame(self, -1, 'regression line with scatter', size=(800,600)) text1="logf = %.03f" %betaZero +" %.03f logr" %betaOne client = plot.PlotCanvas(childFrame2, 2, pos=(300,400),size=(100,200), name=text1) regLine = plot.PolyLine([(0.0, betaZero), ((0.0-(betaZero/betaOne)), 0.0)],width=1, colour='blue') markers = plot.PolyMarker(self.data, legend='Zipf\'s law', colour='red', size=1) gc = plot.PlotGraphics([markers, regLine], text1, 'logr', 'logf') client.Draw(gc, xAxis=(0,15), yAxis = (0,12)) childFrame2.Show(True)
From: CM on 28 Apr 2010 10:09 On Apr 28, 9:13 am, "Kaipo Chang(a)Taiwan" <decomposer17...(a)gmail.com> wrote: > I wrought something like > client = plot.PlotCanvas(childFrame2, 2,pos=(300,400),size=(100,200), > name=text1) > But the plotcanvas kept filling all the childFrame. > Is there a way to Really adjust the size of ploscanvas? > Thanks in advance for your help. In wxPython, if you add a widget directly to a frame it will automatically expand to fill the frame. Instead, add a wxPanel to the frame and add your plot canvas to that panel. wxPython questions are best asked on the wxPython list, which is also on Google Groups or you can email subscribe to it. Che
From: Kaipo Chang on 28 Apr 2010 12:07 Thanks a lot. I'll check the wx list. CM 提到: > On Apr 28, 9:13 am, "Kaipo Chang(a)Taiwan" <decomposer17...(a)gmail.com> > wrote: >> I wrought something like >> client = plot.PlotCanvas(childFrame2, 2,pos=(300,400),size=(100,200), >> name=text1) >> But the plotcanvas kept filling all the childFrame. >> Is there a way to Really adjust the size of ploscanvas? >> Thanks in advance for your help. > > In wxPython, if you add a widget directly to a frame it will > automatically expand to fill the frame. Instead, add a wxPanel to the > frame and add your plot canvas to that panel. > > wxPython questions are best asked on the wxPython list, which is also > on Google Groups or you can email subscribe to it. > > Che
|
Pages: 1 Prev: replacing words in HTML file Next: Advice requested on class design |