class PlotWindow(QtGui.QMainWindow): def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_plotWindow() self.ui.setupUi(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle("Plot window") self.main_widget = QtGui.QWidget(self) l = QtGui.QVBoxLayout(self.main_widget) self.pwidget = MyMplCanvas(self.main_widget, width = 5, height = 4, dpi = 100) ntb = NavigationToolbar(self.pwidget, self.main_widget) l.addWidget(self.pwidget) l.addWidget(ntb) self.setCentralWidget(self.main_widget) def plot_figure(self, data, title, xlabel, xlim = None, ylabel = None, ylim = None, legends = None, fsize = 16): self.fsize = fsize if xlim != None: self.pwidget.axes.set_xlim(xlim) for label in self.pwidget.axes.get_xticklabels() + \ self.pwidget.axes.get_yticklabels(): label.set_fontsize(self.fsize - 2) self.pwidget.axes.set_title(title, fontsize = self.fsize) self.pwidget.axes.set_xlabel(xlabel, fontsize = self.fsize) if ylabel != None: self.pwidget.axes.set_ylabel(ylabel, fontsize = self.fsize) self.pwidget.plot_figure(data) if legends != None: self.pwidget.axes.legend(legends, fontsize = self.fsize) self.pwidget.draw() self.main_widget.setFocus() # self.statusBar().showMessage("All hail matplotlib!", 2000) def closeEvent(self, ce): if (self.parent() != None): self.parent().close_child() self.close()
def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_plotWindow() self.ui.setupUi(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle("Plot window") self.main_widget = QtGui.QWidget(self) l = QtGui.QVBoxLayout(self.main_widget) self.pwidget = MyMplCanvas(self.main_widget, width = 5, height = 4, dpi = 100) ntb = NavigationToolbar(self.pwidget, self.main_widget) l.addWidget(self.pwidget) l.addWidget(ntb) self.setCentralWidget(self.main_widget)