Exemple #1
0
    def _createUi(self) -> None:
        input_box = self._createUi_input_box()

        table_view = QTableView(self)
        self._table_model = EAOCTableModel(
            pd.DataFrame(columns=list(_HEADER_MAP.keys())),
            table_view
        )
        table_view.setModel(self._table_model)
        table_view.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)
        table_view.setMaximumHeight(300)

        self._eaoc_figure = Figure()
        self._eaoc_canvas = FigureCanvasQTAgg(self._eaoc_figure)
        self._eaoc_plt_tbar = NavigationToolbar2QT(self._eaoc_canvas, self)

        self._util_figure = Figure()
        self._util_canvas = FigureCanvasQTAgg(self._util_figure)
        self._util_plt_tbar = NavigationToolbar2QT(self._util_canvas, self)

        layout = QGridLayout()
        layout.addWidget(input_box, 0, 0, 1, 1)
        layout.addWidget(table_view, 0, 1, 1, 3)
        layout.addWidget(self._eaoc_canvas, 1, 0, 1, 2)
        layout.addWidget(self._eaoc_plt_tbar, 2, 0, 1, 2, Qt.AlignCenter)
        layout.addWidget(self._util_canvas, 1, 2, 1, 2)
        layout.addWidget(self._util_plt_tbar, 2, 2, 1, 2, Qt.AlignCenter)
        self.setLayout(layout)
Exemple #2
0
 def setupUi(self, RamaAnalyzerMain):
     Ui_RamaAnalyzerMain.setupUi(self, RamaAnalyzerMain)
     self.residuesListView.setEditTriggers(
         QtWidgets.QAbstractItemView.DoubleClicked
         | QtWidgets.QAbstractItemView.SelectedClicked)
     self.figure = Figure()
     self.canvas = FigureCanvasQTAgg(self.figure)
     self.axes = self.figure.add_subplot(1, 1, 1)
     self.figureVerticalLayout.addWidget(self.canvas)
     self.navigationToolbar = NavigationToolbar2QT(self.canvas,
                                                   self.figureWidget)
     self.figureVerticalLayout.addWidget(self.navigationToolbar)
     self.itemEditorFactory = QtWidgets.QItemEditorFactory()
     self.itemEditorFactory.registerEditor(QtCore.QVariant.Color,
                                           ColorListEditorCreator())
     QtWidgets.QItemEditorFactory.setDefaultFactory(self.itemEditorFactory)
     self.reloadPushButton.clicked.connect(self.reload)
     self.browsePushButton.clicked.connect(self.browse)
     self.stepSlider.sliderMoved.connect(self.sliderMoved)
     self.axes.axis(xmin=-180, ymin=-180, xmax=180, ymax=180)
     self.axes.set_xlabel('$\phi$ (degrees)')
     self.axes.set_ylabel('$\psi$ (degrees)')
     self.axes.vlines([0], -180, 180, colors='k', linestyles='--')
     self.axes.hlines([0], -180, 180, colors='k', linestyles='--')
     self.figure.tight_layout()
     self.canvas.draw()
     self.line = None
     self.stepByStepGroupBox.toggled.connect(self.stepByStepGroupBoxToggled)
     self.stepByStepGroupBox.setEnabled(False)
     self.playMoviePushButton.clicked.connect(self.playMovie)
     self.figurephi = Figure()
     self.canvasphi = FigureCanvasQTAgg(self.figurephi)
     self.axesphi = self.figurephi.add_subplot(1, 1, 1)
     self.figurePhiVerticalLayout = QtWidgets.QVBoxLayout(self.phiTab)
     self.figurePhiVerticalLayout.addWidget(self.canvasphi)
     self.navigationToolbarPhi = NavigationToolbar2QT(
         self.canvasphi, self.phiTab)
     self.figurePhiVerticalLayout.addWidget(self.navigationToolbarPhi)
     self.figurepsi = Figure()
     self.canvaspsi = FigureCanvasQTAgg(self.figurepsi)
     self.axespsi = self.figurepsi.add_subplot(1, 1, 1)
     self.figurePsiVerticalLayout = QtWidgets.QVBoxLayout(self.psiTab)
     self.figurePsiVerticalLayout.addWidget(self.canvaspsi)
     self.navigationToolbarPsi = NavigationToolbar2QT(
         self.canvaspsi, self.psiTab)
     self.figurePsiVerticalLayout.addWidget(self.navigationToolbarPsi)
     self.tabWidget.currentChanged.connect(self.tabSwitched)
     self.hideAllPushButton.clicked.connect(self.hideAllResidues)
Exemple #3
0
    def __init__(self, parent=None):
        super(PlotWidget, self).__init__(parent=None)

        self.main_widget = QWidget(self)

        self.setAttribute(Qt.WA_DeleteOnClose)

        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.plot = plot(self, width=self.PLOT_WIDTH, height=self.PLOT_HEIGHT, dpi=100)

        self.navi_toolbar = NavigationToolbar2QT(self.plot, parent)
        # main_layout.addWidget(self.navi_toolbar)

        main_layout.addWidget(self.plot)

        self.setLayout(main_layout)

        self.actualise_ax()

        imgdata = io.StringIO()
        self.plot.fig.savefig(imgdata, format='svg')
        imgdata.seek(0)
        xmlreader = QXmlStreamReader(imgdata.getvalue())
        self.renderer = QSvgRenderer(xmlreader)
Exemple #4
0
 def __init__(self, main_window):
     self.main_window = main_window
     self.plot = plotter()
     mpl_toolbar = NavigationToolbar2QT(self.plot.fig,
                                        self.main_window.ui.central_widget)
     main_window.ui.FftPlotToolbar.addWidget(mpl_toolbar)
     main_window.ui.FftPlot.addWidget(self.plot.fig)
Exemple #5
0
    def __init__(self, parent):
        self.parent = parent
        self.lmod1 = parent.lmod1
        self.lmod2 = parent.lmod2
        self.showtext = parent.showtext
        self.pbar = self.parent.pbar_sub
        self.xnodes = self.lmod1.custprofx
        self.ynodes = self.lmod1.custprofy
        self.curprof = 0
        self.pcntmax = len(self.xnodes) - 1
        self.viewmagnetics = True

        self.userint = QtWidgets.QWidget()

        self.mmc = MyMplCanvas(self, self.lmod1)
        self.mpl_toolbar = NavigationToolbar2QT(self.mmc, self.userint)

        self.sb_profnum2 = QtWidgets.QSpinBox()
        self.hslider_profile2 = QtWidgets.QSlider()
        self.combo_profpic = QtWidgets.QComboBox()
        self.hs_ppic_opacity = QtWidgets.QSlider()

        self.rb_axis_datamax = QtWidgets.QRadioButton()
        self.rb_axis_profmax = QtWidgets.QRadioButton()
        self.rb_axis_calcmax = QtWidgets.QRadioButton()

        self.sb_profile_linethick = QtWidgets.QSpinBox()
        self.gridlayout_20 = QtWidgets.QGridLayout()
        self.lw_prof_defs = QtWidgets.QListWidget()

        self.pb_add_prof = QtWidgets.QPushButton()
        self.pb_export_csv = QtWidgets.QPushButton()

        self.setupui()
Exemple #6
0
    def __init__(self, parent):
        self.parent = parent
        self.lmod1 = parent.lmod1
        self.lmod2 = parent.lmod2
        self.showtext = parent.showtext
        self.pbar = self.parent.pbar_sub
        self.viewmagnetics = True

        self.userint = QtWidgets.QWidget()

        self.mmc = MyMplCanvas(self, self.lmod1)
        self.mpl_toolbar = NavigationToolbar2QT(self.mmc, self.userint)

        self.sb_profnum = QtWidgets.QSpinBox()
        self.hs_profnum = MySlider()
        self.combo_profpic = QtWidgets.QComboBox()
        self.hs_ppic_opacity = MySlider()
        self.rb_axis_datamax = QtWidgets.QRadioButton()
        self.rb_axis_profmax = QtWidgets.QRadioButton()
        self.rb_axis_calcmax = QtWidgets.QRadioButton()
        self.rb_axis_custmax = QtWidgets.QRadioButton()
        self.dsb_axis_custmin = QtWidgets.QDoubleSpinBox()
        self.dsb_axis_custmax = QtWidgets.QDoubleSpinBox()
        self.sb_profile_linethick = QtWidgets.QSpinBox()
        self.lw_prof_defs = QtWidgets.QListWidget()
        self.pb_prof_rcopy = QtWidgets.QPushButton()
        self.pb_lbound = QtWidgets.QPushButton()
        self.pb_export_csv = QtWidgets.QPushButton()

        self.setupui()
Exemple #7
0
def make_dock_figure():
    '''Create and inject a Figure into the UI

    The user is responsible for the Figure and widget life-cycle.

    Returns
    -------
    f : Figure
    mpl_dock : QtWidgets.QDockWidget

    '''
    # create the Figure
    f = Figure()
    f.stale_callback = lambda obj, val: obj.canvas.draw_idle()

    # set up the Qt widgets we need to inject into the UI
    mpl_dock = QtWidgets.QDockWidget('Matplotlib')
    layout = QtWidgets.QVBoxLayout()
    qw = QtWidgets.QWidget()
    qw.setLayout(layout)
    mpl_dock.setWidget(qw)

    # create the Canvas and toolbar
    cv = FigureCanvas(f)
    mpl_toolbar = NavigationToolbar2QT(cv, qw)

    # add to the layout
    layout.addWidget(cv)
    layout.addWidget(mpl_toolbar)

    # find the main window and add the dock
    mw = get_main_window()
    mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, mpl_dock)

    return f, mpl_dock
Exemple #8
0
 def __init__(self, parent=None, wheel=None):
     QtWidgets.QWidget.__init__(self, parent=None)
     self.canvas = PlotCanvas(wheel=wheel)
     self.vbl = QtWidgets.QVBoxLayout()         # Set box for plotting
     self.vbl.addWidget(self.canvas)
     self.setLayout(self.vbl)
     self.vbl.addWidget(NavigationToolbar2QT(self.canvas, self))
Exemple #9
0
 def tabbed_qt5_window(self) -> None:
     from PyQt5 import QtGui, QtWidgets
     from matplotlib.backends.backend_qt5agg import (FigureCanvasQTAgg,
                                                     NavigationToolbar2QT)
     # mpl backend can already create instance
     # https://stackoverflow.com/a/40031190
     app = QtGui.QGuiApplication.instance()
     if app is None:
         app = QtWidgets.QApplication([self.title])
     self.root_window = QtWidgets.QTabWidget()
     self.root_window.setWindowTitle(self.title)
     sizes = [(0, 0)]
     for name, fig in self.figures.items():
         tab = QtWidgets.QWidget(self.root_window)
         tab.canvas = FigureCanvasQTAgg(fig)
         vbox = QtWidgets.QVBoxLayout(tab)
         vbox.addWidget(tab.canvas)
         toolbar = NavigationToolbar2QT(tab.canvas, tab)
         vbox.addWidget(toolbar)
         tab.setLayout(vbox)
         for axes in fig.get_axes():
             if isinstance(axes, Axes3D):
                 # must explicitly allow mouse dragging for 3D plots
                 self._bind_mouse_events_to_canvas(axes, tab.canvas)
         self.root_window.addTab(tab, name)
         sizes.append(tab.canvas.get_width_height())
     # Resize window to avoid clipped axes.
     self.root_window.resize(*max(sizes))
     self.root_window.show()
     app.exec_()
    def __init__(self, file_atoms):
        QMainWindow.__init__(self)

        self.f = file_atoms  # FileAtoms object

        # # Central widget containing toolbar and plot area

        # ## Toolbar

        l = self.labelDataField = QLabel("&Data field")
        c = self.comboBoxDataField = QComboBox()
        c.addItems(ATOM_ATTR_NAMES)
        l.setBuddy(c)
        l2 = self.labelSpinBox = QLabel("&Bins")
        sb = self.spinBox = QSpinBox()
        sb.setMaximum(MAX_NUM_BINS)
        sb.setValue(50)
        l2.setBuddy(sb)
        b = self.puishButtonPlot = QPushButton("&Plot")
        b.clicked.connect(self.on_plot)

        s = self.spacer0 = QSpacerItem(0, 0, QSizePolicy.Expanding,
                                       QSizePolicy.Minimum)

        bb = [l, c, l2, sb, b]

        l0 = self.layoutToolbar = QHBoxLayout()
        for b in bb:
            l0.addWidget(b)
        l0.addItem(s)
        a = self.widgetPlotToolbar = QWidget()
        a.setLayout(l0)
        a.setFixedHeight(40)

        # ## Plot widget
        # http://stackoverflow.com/questions/12459811
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar2QT(self.canvas, self)
        l1 = self.layoutPlot = QVBoxLayout()
        l1.addWidget(self.toolbar)
        l1.addWidget(self.canvas)
        a99.set_margin(l1, 0)
        # a = self.widgetPlot = QWidget()
        # a.setLayout(l1)

        # ## Mounts central widget
        l2 = self.layoutCentral = QVBoxLayout()
        l2.addWidget(self.widgetPlotToolbar)
        l2.addLayout(l1)
        # l2.addWidget(self.widgetPlot)
        a99.set_margin(l2, 0)
        a = self.centralWidget = QWidget()
        a.setLayout(l2)
        a.setFont(a99.MONO_FONT)
        self.setCentralWidget(self.centralWidget)

        # # Final adjustments
        self.setWindowTitle("Histogram")
        a99.place_center(self)
Exemple #11
0
 def __init__(self):
     super().__init__()
     self.plot_layout = QtWidgets.QVBoxLayout(self)
     self.plot_canvas = MyMplCanvas(width=10, height=4, dpi=100)
     self.navi_toolbar = NavigationToolbar2QT(self.plot_canvas, self)
     self.plot_layout.addWidget(self.navi_toolbar)
     self.plot_layout.addWidget(self.plot_canvas)  # the matplotlib canvas
Exemple #12
0
    def __init__(self, parent):
        super().__init__(parent)
        self.indata = {}
        self.outdata = {}
        self.data = None
        self.parent = parent

        self.setWindowTitle('Edit EDI data')
        helpdocs = menu_default.HelpButton('pygmi.mt.edit')

        vbl = QtWidgets.QVBoxLayout(self)
        hbl = QtWidgets.QHBoxLayout()
        hbl2 = QtWidgets.QHBoxLayout()
        self.mmc = MyMplCanvasPick(self)
        mpl_toolbar = NavigationToolbar2QT(self.mmc, self.parent)

        self.combobox1 = QtWidgets.QComboBox()
        self.combobox2 = QtWidgets.QComboBox()
        self.combobox2.addItems(['xy, yx', 'xx, yy'])
        self.combobox2.setCurrentIndex(0)

        #        self.spinbox = QtWidgets.QDoubleSpinBox()
        #        self.spinbox.setMinimum(0.)
        #        self.spinbox.setMaximum(360.)
        label1 = QtWidgets.QLabel('Station Name:')
        label2 = QtWidgets.QLabel('Graph Type:')
        #        label3 = QtWidgets.QLabel('Rotate Z (0 is North):')
        #        self.checkbox = QtWidgets.QCheckBox('Apply to all stations:')
        pb_apply = QtWidgets.QPushButton('Mask and Interpolate')
        pb_reset = QtWidgets.QPushButton('Reset data')

        buttonbox = QtWidgets.QDialogButtonBox()
        buttonbox.setOrientation(QtCore.Qt.Horizontal)
        buttonbox.setCenterButtons(True)
        buttonbox.setStandardButtons(buttonbox.Cancel | buttonbox.Ok)

        hbl.addWidget(label1)
        hbl.addWidget(self.combobox1)
        hbl.addWidget(label2)
        hbl.addWidget(self.combobox2)
        #        hbl.addWidget(label3)
        #        hbl.addWidget(self.spinbox)

        hbl2.addWidget(helpdocs)
        hbl2.addWidget(pb_reset)
        hbl2.addWidget(pb_apply)

        vbl.addWidget(self.mmc)
        vbl.addWidget(mpl_toolbar)
        #       vbl.addWidget(self.checkbox)
        vbl.addLayout(hbl)
        vbl.addLayout(hbl2)
        vbl.addWidget(buttonbox)

        pb_apply.clicked.connect(self.apply)
        pb_reset.clicked.connect(self.reset_data)
        buttonbox.accepted.connect(self.accept)
        buttonbox.rejected.connect(self.reject)
        self.combobox2.currentIndexChanged.connect(self.change_band)
        self.combobox1.currentIndexChanged.connect(self.change_band)
Exemple #13
0
    def __init__(self, view_model: PlotViewModel, width, height, parent, layout, dpi=100):
        self.view_model = view_model

        fig = Figure(figsize=(width, height), dpi=dpi, tight_layout=True)
        FigureCanvasQTAgg.__init__(self, fig)
        self.setParent(parent)
        self.navigation_toolbar = NavigationToolbar2QT(self, self)
        layout.addWidget(self.navigation_toolbar)

        filter_spin_label = QLabel(self.view_model.filter_spin_label_text, self)
        self.navigation_toolbar.addWidget(filter_spin_label)

        filter_spin = QSpinBox(self)
        filter_spin.valueChanged.connect(self._filter_spin_value_changed)
        self.navigation_toolbar.addWidget(filter_spin)

        close_button = QPushButton(self.view_model.close_button_text) #QAction(QIcon(self.view_model.close_button_icon_path), self.view_model.close_button_text, self)
        # close_button.setShortcut('Ctrl+Shift+Q')
        #close_button.setStatusTip()
        close_button.clicked.connect(self._close_button_click)
        self.navigation_toolbar.addWidget(close_button)

        subtract_comobobox = Controls.Che

        self.axes = self.figure.subplots()
        self.axes.format_coord = lambda x, y: ""
        self.view_model.load_data()

        self._show_plot()
Exemple #14
0
    def __init__(self, parent):
        super().__init__(parent)
        self.parent = parent

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle('Graph Window')

        vbl = QtWidgets.QVBoxLayout(self)
#        hbl = QtWidgets.QHBoxLayout()
        self.mmc = MyMplCanvas(self)
        mpl_toolbar = NavigationToolbar2QT(self.mmc, self.parent)

#        self.combobox1 = QtWidgets.QComboBox()
#        self.combobox2 = QtWidgets.QComboBox()
#        self.label1 = QtWidgets.QLabel('Bands:')
#        self.label2 = QtWidgets.QLabel('Bands:')
#
#        hbl.addWidget(self.label1)
#        hbl.addWidget(self.combobox1)
#        hbl.addWidget(self.label2)
#        hbl.addWidget(self.combobox2)

        vbl.addWidget(self.mmc)
        vbl.addWidget(mpl_toolbar)
#        vbl.addLayout(hbl)

        self.setFocus()
Exemple #15
0
    def __init__(self, parent):
        QtWidgets.QDialog.__init__(self, parent)
        self.indata = {}
        self.outdata = {}
        self.parent = parent
        self.m1 = 0
        self.c = [0, 1, 0]
        self.m = [0, 0]
        self.df = None

        self.map = GraphMap(self)
        self.dpoly = QtWidgets.QPushButton('Delete Polygon')
        self.apoly = QtWidgets.QPushButton('Add Polygon')
        self.combo = QtWidgets.QComboBox()
        self.combo_class = QtWidgets.QComboBox()
        self.tablewidget = QtWidgets.QTableWidget()
        self.KNalgorithm = QtWidgets.QComboBox()
        self.SVCkernel = QtWidgets.QComboBox()
        self.DTcriterion = QtWidgets.QComboBox()
        self.RFcriterion = QtWidgets.QComboBox()
        self.label1 = QtWidgets.QLabel()

        self.mpl_toolbar = NavigationToolbar2QT(self.map, self.parent)

        self.setupui()

        self.map.mindx = self.m
Exemple #16
0
    def set_data(self, u, z):
        self.setWindowTitle('Zernike coefficients')
        frame = QFrame()
        figplot = FigureCanvas(Figure(figsize=(7, 5)))
        layout = QGridLayout()
        frame.setLayout(layout)
        nav = NavigationToolbar2QT(figplot, frame)
        layout.addWidget(nav, 0, 0)
        layout.addWidget(figplot, 1, 0)
        figplot.figure.subplots_adjust(left=.125,
                                       right=.9,
                                       bottom=.1,
                                       top=.9,
                                       wspace=0.45,
                                       hspace=0.45)
        self.figplot = figplot

        gs = GridSpec(2, 1)
        ax0 = figplot.figure.add_subplot(gs[0, 0])
        ax0.plot(u, marker='.')
        ax0.grid()
        ax0.set_xlabel('actuators')
        ax0.set_ylim((-1, 1))
        ax1 = figplot.figure.add_subplot(gs[1, 0])
        ax1.plot(range(1, z.size + 1), z, marker='.')
        ax1.grid()
        ax1.set_xlabel('Noll')
        ax1.set_ylabel('[rad]')

        self.ax0 = ax0
        self.ax1 = ax1

        l1 = QGridLayout()
        self.setLayout(l1)
        l1.addWidget(frame)
Exemple #17
0
    def __init__(self, figure: 'Figure', title: str = 'Diagramm',
                 modal: bool = False):
        '''
        Parameters
        ----------
        figure : Figure
            the matplotlib figure to display
        title : str, optional
            the title of the dialog, defaults to 'Diagramm'
        modal : bool, optional
            the modality of the dialog (modal if True, modeless if False),
            defaults to being modal
        '''
        super().__init__(modal=modal, title=title, parent=iface.mainWindow())
        # it takes the `figure` instance as a parameter to __init__
        self.canvas = FigureCanvasQTAgg(figure)

        # this is the Navigation widget
        # it takes the Canvas widget and a parent
        self.toolbar = NavigationToolbar2QT(self.canvas, self)

        # set the layout
        layout = QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)
        self.setLayout(layout)
Exemple #18
0
    def __init__(self, setup: Setup):
        super().__init__()
        self.setWindowFlags(Qt.Window)
        self.setWindowTitle("Composite Enthalpy Diagram")

        self._setup = setup

        self._figure = Figure()
        self._canvas = FigureCanvasQTAgg(self._figure)
        self._plt_toolbar = NavigationToolbar2QT(self._canvas, self)

        slider = QSlider(self)
        self._slider = slider
        slider.setValue(self._setup.dt)
        slider.setMinimum(5)
        slider.setMaximum(30)
        slider.setSingleStep(2)
        slider.setOrientation(Qt.Horizontal)
        slider.sliderReleased.connect(self._on_dt_changed)

        setup.dt_changed.connect(self._plot_graph)

        layout = QVBoxLayout()
        layout.addWidget(slider)
        layout.addWidget(self._canvas)
        layout.addWidget(self._plt_toolbar)
        self.setLayout(layout)

        self._plot_graph()
Exemple #19
0
 def tabbed_qt5_window(self) -> None:
     from PyQt5 import QtGui, QtWidgets
     from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT
     # mpl backend can already create instance
     # https://stackoverflow.com/a/40031190
     app = QtGui.QGuiApplication.instance()
     if app is None:
         app = QtWidgets.QApplication([self.title])
     self.root_window = QtWidgets.QTabWidget()
     self.root_window.setWindowTitle(self.title)
     for name, fig in self.figures.items():
         tab = QtWidgets.QWidget(self.root_window)
         tab.canvas = FigureCanvasQTAgg(fig)
         vbox = QtWidgets.QVBoxLayout(tab)
         vbox.addWidget(tab.canvas)
         toolbar = NavigationToolbar2QT(tab.canvas, tab)
         vbox.addWidget(toolbar)
         tab.setLayout(vbox)
         for axes in fig.get_axes():
             if isinstance(axes, Axes3D):
                 # must explicitly allow mouse dragging for 3D plots
                 axes.mouse_init()
         self.root_window.addTab(tab, name)
     self.root_window.show()
     app.exec_()
Exemple #20
0
    def setupUi(self, is_toolbar=True, is_horizontal=False):
        # toolbar; only use 'vertical' with coordinates 'False' due to size issue
        coords = False
        orient = Qt.Vertical
        if is_horizontal:
            coords = True
            orient = Qt.Horizontal

        # === Widgets ===
        self.canvas = MPLCanvas()
        self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.toolbar = NavigationToolbar2QT(self.canvas,
                                            self,
                                            coordinates=coords)
        self.toolbar.setOrientation(orient)

        # === Layout ===
        if is_horizontal:  # the layout is opposite to the toolbar orientation
            self.mainLayout = QVBoxLayout()
        else:
            self.mainLayout = QHBoxLayout()

        if is_toolbar:
            self.mainLayout.addWidget(self.toolbar)
        self.mainLayout.addWidget(self.canvas)
        self.setLayout(self.mainLayout)
Exemple #21
0
    def __init__(self, with_toolbar=False, with_zoom=False):

        self.plt = plt
        self.figure = self.plt.figure()

        layout = QVBoxLayout()
        self.widget = QWidget()
        self.widget.setLayout(layout)
        self.canvas = FigureCanvasQTAgg(self.figure)

        self.current_axis = None

        if with_toolbar:
            self.toolbar = NavigationToolbar2QT(self.canvas, self.canvas)
            layout.addWidget(self.toolbar)
            self.toolbar.pan()

        layout.addWidget(self.canvas)

        if with_zoom:
            def _zoom(e):
                factor = 2 if e.button == 'down' else 0.5
                xlim, ylim = self.current_axis.get_xlim(), self.current_axis.get_ylim()
                self.current_axis.set_xlim(
                    xlim[0] + (xlim[1] - xlim[0])*0.5 - (xlim[1] - xlim[0])*0.5*factor,
                    xlim[0] + (xlim[1] - xlim[0])*0.5 + (xlim[1] - xlim[0])*0.5*factor
                )
                self.current_axis.set_ylim(
                    ylim[0] + (ylim[1] - ylim[0])*0.5 - (ylim[1] - ylim[0])*0.5*factor,
                    ylim[0] + (ylim[1] - ylim[0])*0.5 + (ylim[1] - ylim[0])*0.5*factor
                )
                self.canvas.draw()
            self.canvas.mpl_connect('scroll_event', _zoom)
    def __init__(self, bottom_dock=True, left_dock=True):
        # initialsie window
        QMainWindow.__init__(self)
        self.main_widget = QWidget(self)

        # add dock widget
        if bottom_dock:
            self.bottom_dock = QDockWidget()
            self.addDockWidget(Qt.BottomDockWidgetArea, self.bottom_dock)
            self.bottom_dock.setFeatures(QDockWidget.DockWidgetFloatable)

        if left_dock:
            self.left_dock = QDockWidget()
            self.addDockWidget(Qt.LeftDockWidgetArea, self.left_dock)
            self.left_dock.setFeatures(QDockWidget.DockWidgetFloatable)

        # define layout
        self.grid = QGridLayout(self.main_widget)

        # create figure on window
        self.canvas = MPLCanvas()
        self.grid.addWidget(self.canvas, 0, 0, 1, 1)  # all rows

        # figure toolbar
        toolbar = NavigationToolbar2QT(self.canvas, self)
        self.grid.addWidget(toolbar, 1, 0, 1, 1)

        self.setCentralWidget(self.main_widget)
Exemple #23
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.parent = parent

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle('Graph Window')

        vbl = QtWidgets.QVBoxLayout(self)  # self is where layout is assigned
        hbl = QtWidgets.QHBoxLayout()
        self.mmc = MyMplCanvas(self)
        mpl_toolbar = NavigationToolbar2QT(self.mmc, self.parent)

        self.combobox1 = QtWidgets.QComboBox()
        self.combobox2 = QtWidgets.QComboBox()
        self.label1 = QtWidgets.QLabel('Bands:')
        self.label2 = QtWidgets.QLabel('Bands:')

        hbl.addWidget(self.label1)
        hbl.addWidget(self.combobox1)
        hbl.addWidget(self.label2)
        hbl.addWidget(self.combobox2)

        vbl.addWidget(self.mmc)
        vbl.addWidget(mpl_toolbar)
        vbl.addLayout(hbl)

        self.setFocus()

        self.combobox1.currentIndexChanged.connect(self.change_band)
        self.combobox2.currentIndexChanged.connect(self.change_band)
 def __init__(self, parent=None, *args, **kwargs):  # x, y, name='',
     super(Graph, self).__init__(parent=parent, *args, **kwargs)
     self.canvas = PlotCanvas(parent)
     self.toolbar = NavigationToolbar2QT(self.canvas, self)
     self.setLayout(QVBoxLayout())
     self.layout().addWidget(self.toolbar)
     self.layout().addWidget(self.canvas)
def show_tabbed_plots(pc):
    from PyQt5 import QtGui, QtWidgets
    from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    # make qt5 application
    app = QtGui.QGuiApplication.instance()
    if app == None:
        app = QtWidgets.QApplication([pc.title])
    # setup plot_collection
    pc.root_window = QtWidgets.QTabWidget()
    pc.root_window.setWindowTitle(pc.title)
    for name, fig in pc.figures.items():
        tab = QtWidgets.QWidget(pc.root_window)
        tab.canvas = FigureCanvasQTAgg(fig)
        vbox = QtWidgets.QVBoxLayout(tab)
        vbox.addWidget(tab.canvas)
        toolbar = NavigationToolbar2QT(tab.canvas, tab)
        vbox.addWidget(toolbar)
        tab.setLayout(vbox)
        for axes in fig.get_axes():
            if isinstance(axes, Axes3D):
                axes.mouse_init()  # to allow for dragging 3D plot with mouse
        pc.root_window.addTab(tab, name)
    pc.root_window.show()
    app.exec_()
    plt.close('all')
Exemple #26
0
    def _refresh_mpl_widget(self):
        """ Create the mpl widget and update the underlying control.

        """
        # Delete the old widgets in the layout, it's just shenanigans
        # to try to reuse the old widgets when the figure changes.
        widget = self.widget
        layout = widget.layout()
        while layout.count():
            layout_item = layout.takeAt(0)
            layout_item.widget().deleteLater()

        # Create the new figure and toolbar widgets. It seems that key
        # events will not be processed without an mpl figure manager.
        # However, a figure manager will create a new toplevel window,
        # which is certainly not desired in this case. This appears to
        # be a limitation of matplotlib. The canvas is manually set to
        # visible, or QVBoxLayout will ignore it for size hinting.
        figure = self.declaration.figure
        if figure:
            canvas = FigureCanvasQTAgg(figure)
            canvas.setParent(widget)
            canvas.setFocusPolicy(Qt.ClickFocus)
            canvas.setVisible(True)
            toolbar = NavigationToolbar2QT(canvas, widget)
            toolbar.setVisible(self.declaration.toolbar_visible)
            layout.addWidget(toolbar)
            layout.addWidget(canvas)
Exemple #27
0
    def init_graphauxlayout(self):
        ''' In graphLayout - Initialization the two bottom figures on the window'''

        graphauxlayout = QHBoxLayout()
        ga1layout = QVBoxLayout()
        ga2layout = QVBoxLayout()

        fit_fig = Figure(figsize=(2, 2), dpi=100)
        self.fit_fc = FigureCanvas(fit_fig)
        self.fit_fc.setSizePolicy(1, 0)
        self.fit_ax = self.fit_fc.figure.add_subplot(111)
        self.fit_ax.tick_params(labelsize=8)
        ga1layout.addWidget(self.fit_fc)
        self.fit_fc.draw()

        en_fig = Figure(figsize=(2, 2), dpi=100)
        self.en_fc = FigureCanvas(en_fig)
        #self.en_fc.setSizePolicy(1, 0)
        self.en_ax = self.en_fc.figure.add_subplot(111)
        self.en_ax.tick_params(labelsize=8)
        self.en_fc.draw()
        en_nav = NavigationToolbar2QT(self.en_fc, self)
        en_nav.setStyleSheet("QToolBar { border: 0px }")
        ga2layout.addWidget(self.en_fc)
        ga2layout.addWidget(en_nav)

        graphauxlayout.addLayout(ga1layout)
        graphauxlayout.addLayout(ga2layout)
        self.graphlayout.addLayout(graphauxlayout)
    def __init__(self, mainWindow, *args, **kwargs):
        super(GraphWindow, self).__init__(*args, **kwargs)

        uic.loadUi(os.path.join(sys.path[0], 'UI/GraphWindow.ui'), self)

        self.setWindowTitle('Live Gold Graph')
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.parentWindow = mainWindow
        self.show()

        self.toolbar = NavigationToolbar2QT(self.canvas, self)

        self.mul = 1
        self.SaveButton.clicked.connect(self.toolbar.save_figure)
        self.EndGame.clicked.connect(self.parentWindow.endGame)
        self.StartGame.clicked.connect(self.parentWindow.startGame)
        self.btn1.clicked.connect(
            lambda: self.parentWindow.updateTime(1 * self.mul))
        self.btn2.clicked.connect(
            lambda: self.parentWindow.updateTime(5 * self.mul))
        self.btn3.clicked.connect(
            lambda: self.parentWindow.updateTime(10 * self.mul))
        self.btn4.clicked.connect(
            lambda: self.parentWindow.updateTime(30 * self.mul))
        self.minus.toggled.connect(
            lambda selected: self.changeMul(selected, -1))
        self.plus.toggled.connect(lambda selected: self.changeMul(selected, 1))

        # Setup a timer to trigger the redraw by calling update_plot.
        self.timer = QtCore.QTimer()
        self.timer.setInterval(500)
        self.timer.timeout.connect(self.updatePlot)
        self.timer.start()
Exemple #29
0
    def __init__(self, parent=None, name="plot window"):
        QMainWindow.__init__(self, parent)

        self.setWindowTitle(name)
        self.setObjectName(name)
        self.resize(800, 600)
        self.centralwidget = QWidget(self)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.gridLayout = QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.imageLayout = QVBoxLayout()
        self.imageLayout.setObjectName(_fromUtf8("imageLayout"))
        self.gridLayout.addLayout(self.imageLayout, 0, 0, 1, 1)
        self.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 550, 21))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(self)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        self.setStatusBar(self.statusbar)

        QtCore.QMetaObject.connectSlotsByName(self)

        ###
        #matplotlib setup

        self.fig1 = Figure()
        self.ax1 = self.fig1.add_subplot(111)

        self.canvas = FigureCanvas(self.fig1)
        self.toolbar = NavigationToolbar2QT(self.canvas, None)

        self.imageLayout.addWidget(self.canvas)
        self.imageLayout.addWidget(self.toolbar)
Exemple #30
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.view = FigureCanvas(Figure(figsize=(5, 3)))
        self.axes = self.view.figure.subplots()
        self.toolbar = NavigationToolbar2QT(self.view, self)
        self.mu_input = QDoubleSpinBox()
        self.std_input = QDoubleSpinBox()

        input_layout = QHBoxLayout()
        input_layout.addWidget(self.mu_input)
        input_layout.addWidget(self.std_input)

        self.button = QPushButton("valider")
        vlayout = QVBoxLayout()

        self.mu_input.setPrefix("μ: ")
        self.std_input.setPrefix("σ: ")
        self.std_input.setValue(10)

        vlayout.addWidget(self.toolbar)
        vlayout.addWidget(self.view)
        vlayout.addLayout(input_layout)
        vlayout.addWidget(self.button)
        self.setLayout(vlayout)

        self.button.clicked.connect(self.on_valid)

        self.on_valid()