Keeping a zoomed view when adding to a plot

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>

Aaron R> wrote:

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.

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

Try this:
         self.axes.set_autoscale_on(False)

Eric

···

  self.axes.plot(xdata, ydata)

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

Sorry for the delay in responding.

This worked perfectly! Thanks so much for the time saver.

Kind regards,
Aaron R>

···

On Thu, Feb 26, 2009 at 12:28 PM, Eric Firing <efiring@...202...> wrote:

Aaron R> wrote:

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.

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

Try this:
self.axes.set_autoscale_on(False)

Eric

   self\.axes\.plot\(xdata, ydata\)

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