code: def connect(self):
          
          self._cidmotion = self.canvas.mpl_connect('motion_notify_event',
                                                    self.onmove)
          self._ciddraw = self.canvas.mpl_connect('draw_event', self.clear)
docs: connect events