def __init__(self): interactive = matplotlib.is_interactive() matplotlib.interactive(False) # setup Matplotlib Figure and Axis self.fig = Figure(facecolor='#ffffff') try: self.fig.set_tight_layout(True) except AttributeError: # matplotlib < 1.1 pass # initialization of the canvas FigureCanvas.__init__(self, self.fig) # we define the widget as expandable FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) # notify the system of updated policy FigureCanvas.updateGeometry(self) self.manager = FigureManager(self, 0) matplotlib.interactive(interactive)
def __init__(self, parent=None, title='', xlabel='', ylabel='', xlim=None, ylim=None, xscale='linear', yscale='linear', width=4, height=3, dpi=100): self.figure = Figure(figsize=(width, height), dpi=dpi) self.figure.patch.set_facecolor([0, 1, 0, 0]) self.axes = self.figure.add_subplot(111) self.axes.set_title(title) self.axes.set_xlabel(xlabel) self.axes.set_ylabel(ylabel) if xscale is not None: self.axes.set_xscale(xscale) if yscale is not None: self.axes.set_yscale(yscale) if xlim is not None: self.axes.set_xlim(*xlim) if ylim is not None: self.axes.set_ylim(*ylim) Canvas.__init__(self, self.figure) self.setParent(parent) Canvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) Canvas.updateGeometry(self) self.manager = FigureManager(self, 1) self.manager._cidgcf = self.figure