I have an app which adds data to a plot.  Everything is working, but
when I add data to a plot that was zoomed in, it switches the display
to a zoomed out view.

Here's a code snippet:

class MyPlotFrame(Frame):

    def __init__(self):
        Frame.__init__(self,None,-1,
                         'My Super Frame',size=(550,350))

        self.SetBackgroundColour(NamedColor("WHITE"))

        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)

        t = arange(0.0,3.0,0.01)
        s = sin(2*pi*t)

        self.axes.plot(t,s)
        self.axes.grid()
        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = BoxSizer(VERTICAL)
        self.sizer.Add(self.canvas, 1, LEFT | TOP | GROW)
        self.SetSizer(self.sizer)
        self.Fit()

        self.add_toolbar()  # comment this out for no toolbar

    def addData(self, xdata, ydata):
        # Need to save off current zoom level before adding new plot data
        # But don't know how
        self.axes.plot(xdata, ydata)

        # Restore view here, then redraw
        self.canvas.draw()

    def add_toolbar(self):
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        # Snipped some stuff for checking if on a Mac or Windows
        self.toolbar.update()

    def OnPaint(self, event):
        self.canvas.draw()


I can't find any examples or docs on maintaining my zoom of the plot.
In matlab, I know how to do this, but I'm not sure what to do here.
Can someone please advise?

Thanks,
Aaron R>

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to