anumated plot with autscaling axises

Good day!
Could You please tell me how can I get axises autoscaling in the animated plot example. I've take an example and have modifyed it slightly so the second line in plot gets out of bounding box during animation. What I need is autoscaling of axises during animation. Please point mee what I have to do.

Thanks a lot!

Hereafter a modifyed example:



# For detailed comments on animation and the techniqes used here, see
# the wiki entry

import sys

from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas

from PyQt4 import QtGui

ITERS = 100

import numpy as np
import time

class BlitQT(FigureCanvas):
     def __init__(self):
         FigureCanvas.__init__(self, Figure())
 = self.figure.add_subplot(111)

         self.old_size =,
         self.ax_background = self.copy_from_bbox(
         self.cnt = 0

         self.x = np.arange(0,2*np.pi,0.01)
         self.sin_line, =, np.sin(self.x), animated=True)
         self.cos_line, =, np.cos(self.x), animated=True)

         self.tstart = time.time()

     def timerEvent(self, evt):
         current_size =,
         if self.old_size != current_size:
             self.old_size = current_size
             self.ax_background = self.copy_from_bbox(


         # update the data
         # just draw the animated artist
         # just redraw the axes rectangle

         if self.cnt == 0:
             # TODO: this shouldn't be necessary, but if it is excluded the
             # canvas outside the axes is not initially painted.
         if self.cnt==ITERS:
             # print the timing info and quit
             print 'FPS:' , ITERS/(time.time()-self.tstart)
             self.cnt += 1

app = QtGui.QApplication(sys.argv)
widget = BlitQT()