code: def _connect_callbacks(self):
          
          figure = self.get_figure()
          callback = partial(mpl_redraw_callback, tax=self)
          event_names = ('resize_event', 'draw_event')
          for event_name in event_names:
              figure.canvas.mpl_connect(event_name, callback)
docs: Connect resize matplotlib callbacks.