wxPython problem: Can't assign size of plot.PlotCanvas

Discussion in 'Python' started by Kaipo Chang@Taiwan, Apr 28, 2010.

  1. 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)
     
    Kaipo Chang@Taiwan, Apr 28, 2010
    #1
    1. Advertising

  2. Kaipo Chang@Taiwan

    CM Guest

    On Apr 28, 9:13 am, "Kaipo Chang@Taiwan" <>
    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
     
    CM, Apr 28, 2010
    #2
    1. Advertising

  3. Thanks a lot.
    I'll check the wx list.

    CM æ到:
    > On Apr 28, 9:13 am, "Kaipo Chang@Taiwan" <>
    > 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
     
    Kaipo Chang@Taiwan, Apr 28, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Hunter
    Replies:
    2
    Views:
    2,580
    Dr. Colombes
    Oct 20, 2004
  2. Dr. Colombes
    Replies:
    1
    Views:
    1,038
    John Hunter
    Feb 10, 2005
  3. Jolley
    Replies:
    1
    Views:
    1,198
    Jolley
    Nov 23, 2006
  4. Jacob Davis
    Replies:
    2
    Views:
    555
    Jacob Davis
    Feb 23, 2008
  5. Leo Lee
    Replies:
    3
    Views:
    391
    Leo Lee
    Jul 17, 2008
Loading...

Share This Page