def __init__(self, parent, width=10, height=6, dpi=72, maincanvas=False): fig = Figure(figsize=(width, height), dpi=dpi) fig.set_facecolor('white') self.print_width = 0 self.main = parent self.logz = False self.axes = fig.add_subplot(111) self.plotter = DataPlotter(self, self.axes) # make tight_layout do the right thing self.axes.set_xlabel('x') self.axes.set_ylabel('y') self.axes.set_title('(data title)\n(info)') FigureCanvas.__init__(self, fig) # create a figure manager so that we can use pylab commands on the # main viewport def make_active(event): Gcf.set_active(self.manager) self.manager = FigureManagerQT(self, 1) self.manager._cidgcf = self.mpl_connect('button_press_event', make_active) Gcf.set_active(self.manager) self.setParent(parent) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.updateGeometry() # actually get key events self.setFocusPolicy(Qt.StrongFocus) self.mpl_connect('key_press_event', self.key_press) # These will not do anything in standalone mode, but do not hurt. if maincanvas: session.propsRequested.connect(self.on_session_propsRequested) session.propsUpdated.connect(self.on_session_propsUpdated)
def __enter__(self): # delay loading pylab until matplotlib.use() is called import pylab from matplotlib._pylab_helpers import Gcf # Note: don't need to track and restore the current active since it # will automatically be restored when we pop the current figure. Gcf.set_active(self.fm) return pylab
def __enter__(self): # delay loading pylab until matplotlib.use() is called import pylab from matplotlib._pylab_helpers import Gcf Gcf.set_active(self.fm) return pylab
def _window_activated(self): Gcf.set_active(self)
def make_active(event): Gcf.set_active(self.manager)
def __enter__(self): Gcf.set_active(self.fm) return pylab
def __enter__(self): Gcf.set_active(self.fm)
def setactive(cls, pane): """set the active figure""" if pane and isinstance(pane, MatplotPanel): Gcf.set_active(pane)