Beispiel #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)
Beispiel #2
0
    def initialize(self):

        # Set the display position of the mainwindow.
        desktop = QApplication.desktop()
        x = (desktop.width() - self.width()) // 2
        y = (desktop.height()-65 - self.height()) // 2
        self.move(x, y)

        # Desine the translator to translate interface languages.
        self.trans = QTranslator(self)
        # Define the Result class to record the results in the process.
        self.result = Result()
        # Define the fdem forward simulation thread class.
        self.thread_cal_fdem = ThreadCalFdem()
        # Define the fdem inversion thread class.
        self.thread_inv_fdem = ThreadInvFdem()

        # Define the figure to show data in the interface.
        self.fig_scenario = Figure(figsize=(4.21, 3.91))
        self.canvas_scenario = FigureCanvasQTAgg(self.fig_scenario)
        self.gl_detection_scenario.addWidget(self.canvas_scenario)

        self.fig_discretize = Figure(figsize=(4.21, 3.91))
        self.canvas_discretize = FigureCanvasQTAgg(self.fig_discretize)
        self.gl_discretize.addWidget(self.canvas_discretize)

        self.fig_magnetic_field = Figure(figsize=(4.21, 3.91))
        self.canvas_magnetic_field = FigureCanvasQTAgg(self.fig_magnetic_field)
        self.gl_magnetic_field_data.addWidget(self.canvas_magnetic_field)

        self.pbar_rfs.setVisible(False)
        self.pbar_rfi.setVisible(False)
Beispiel #3
0
    def __init__(self, parent=None):
        super(AlphaViewAppUI, self).__init__(parent)
        self.setupUi(self)

        self.user_data = {}
        self.rmq = RabbitMqThread(self.user_data, self.listWidget,
                                  self.update_user_state)
        self.start_mqthread()

        # init image classifier graph
        self.figure_imgcls = Figure()
        self.canvas_imgcls = FigureCanvasQTAgg(self.figure_imgcls)
        self.axis_imgcls = self.figure_imgcls.add_subplot(111)
        self.axis_imgcls.set(title="Image classifier",
                             xlabel="classes",
                             ylabel="# images")

        # init mood text graph
        self.figure_mood = Figure()
        self.canvas_mood = FigureCanvasQTAgg(self.figure_mood)
        self.axis_mood = self.figure_mood.add_subplot(111)
        self.axis_mood.xaxis.set_major_locator(MaxNLocator(integer=True))
        self.axis_mood.set(title="Sentiments analyser from text",
                           xlabel="# Messages",
                           ylabel="Mood")
        self.classes = ['airplane', 'automobile', 'ship', 'truck']

        self.plot_classifier_images_graph([0])
        self.plot_text_mood_graph([0])

        self.verticalLayoutText.addWidget(self.canvas_mood)
        self.verticalLayoutImages.addWidget(self.canvas_imgcls)

        self.listWidget.currentItemChanged.connect(self.update_user_state)
Beispiel #4
0
    def draw_rod_his_gp(self):
        # 위 그래프
        self.rod_cond = plt.figure()
        self.rod_cond_ax = self.rod_cond.add_subplot(111)
        self.rod_cond_canv = FigureCanvasQTAgg(self.rod_cond)
        self.Trend_ui.Rod_his_cond.addWidget(self.rod_cond_canv)

        # 아래 제어신호
        self.rod_fig = plt.figure()
        self.rod_ax = self.rod_fig.add_subplot(111)
        self.rod_canvas = FigureCanvasQTAgg(self.rod_fig)
        self.Trend_ui.Rod_his.addWidget(self.rod_canvas)
Beispiel #5
0
 def add_layout_reward(self, layout):
     widget = QtWidgets.QTabWidget()
     fig = plt.figure()
     fig.subplots_adjust(top=1, bottom=0, right=1, hspace=0, wspace=0)
     canvas = FigureCanvasQTAgg(fig)
     widget.addTab(canvas, '')
     for name in self.problem.context['name_reward']:
         fig = plt.figure()
         fig.subplots_adjust(top=1, bottom=0, right=1, hspace=0, wspace=0)
         canvas = FigureCanvasQTAgg(fig)
         widget.addTab(canvas, name)
     widget.setFocusPolicy(QtCore.Qt.NoFocus)
     layout.addWidget(widget)
     return widget
Beispiel #6
0
    def __init__(self):
        super(myDialog, self).__init__()
        self.setupUi(self)

        self.horizontalSlider1.sliderReleased.connect(
            self.sliderReleased_Event)
        self.horizontalSlider2.sliderReleased.connect(
            self.sliderReleased_Event)
        self.horizontalSlider3.sliderReleased.connect(
            self.sliderReleased_Event)

        list = ['Low Pass', 'High Pass', 'Band Pass', 'Band Stop']
        self.comboBoxFilterType.clear()
        self.comboBoxFilterType.addItems(list)
        self.comboBoxFilterType.currentIndexChanged.connect(
            self.comboBoxCurrentIndexChanged_Event)
        self.comboBoxFilterType.setCurrentIndex(0)
        self.buttonSet.clicked.connect(self.buttonClicked_Event)

        rx = QRegExp("\d+")
        self.textBoxFl.setValidator(QRegExpValidator(rx))
        self.textBoxFh.setValidator(QRegExpValidator(rx))

        self.textBoxFh.setEnabled(False)

        self.spinBoxOrder.valueChanged.connect(self.spinBoxValueChanged_Event)
        self.spinBoxOrder.setValue(order)

        self.fig1 = Figure()
        canvas = FigureCanvasQTAgg(self.fig1)
        toolbar = NavigationToolbar(canvas, self)

        layout1 = QVBoxLayout()
        layout1.addWidget(canvas)
        layout1.addWidget(toolbar)

        self.widget1.setLayout(layout1)
        self.widget1.show()

        self.fig2 = Figure()
        canvas = FigureCanvasQTAgg(self.fig2)
        toolbar = NavigationToolbar(canvas, self)

        layout2 = QVBoxLayout()
        layout2.addWidget(canvas)
        layout2.addWidget(toolbar)

        self.widget2.setLayout(layout2)
        self.widget2.show()
Beispiel #7
0
 def _drwFigs(self):
     # TODO: сделать вывод гистограммы
     figIn, figOut = Figure(), Figure()
     figIn.set_tight_layout({
         'pad': 0,
     })
     figOut.set_tight_layout({
         'pad': 0,
     })
     self.axIn = figIn.add_subplot(111)
     self.axOut = figOut.add_subplot(111)
     self.iFig, self.oFig = FigureCanvasQTAgg(figIn), FigureCanvasQTAgg(
         figOut)
     self.gridLayout.addWidget(self.iFig, 1, 2, 1, 1)
     self.gridLayout.addWidget(self.oFig, 3, 2, 1, 1)
Beispiel #8
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)
Beispiel #9
0
 def __init__(self, brain, width, height, dpi):
     from PyQt5 import QtWidgets
     from matplotlib import rc_context
     from matplotlib.figure import Figure
     from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
     if brain.separate_canvas:
         parent = None
     else:
         parent = brain.window
     # prefer constrained layout here but live with tight_layout otherwise
     context = nullcontext
     extra_events = ('resize', )
     try:
         context = rc_context({'figure.constrained_layout.use': True})
         extra_events = ()
     except KeyError:
         pass
     with context:
         self.fig = Figure(figsize=(width, height), dpi=dpi)
     self.canvas = FigureCanvasQTAgg(self.fig)
     self.axes = self.fig.add_subplot(111)
     self.axes.set(xlabel='Time (sec)', ylabel='Activation (AU)')
     self.canvas.setParent(parent)
     FigureCanvasQTAgg.setSizePolicy(self.canvas,
                                     QtWidgets.QSizePolicy.Expanding,
                                     QtWidgets.QSizePolicy.Expanding)
     FigureCanvasQTAgg.updateGeometry(self.canvas)
     self.brain = brain
     self.time_func = brain.callbacks["time"]
     for event in ('button_press', 'motion_notify') + extra_events:
         self.canvas.mpl_connect(event + '_event',
                                 getattr(self, 'on_' + event))
Beispiel #10
0
def new_figure_manager_given_figure(num, figure):
    """
    Create a new figure manager instance for the given figure.
    """
    canvas = FigureCanvasQTAgg(figure)
    manager = FigureManagerWorkbench(canvas, num)
    return manager
 def __init__(self):
     super(NewApp, self).__init__()
     self.setupUi(self)
     self.btn_atras.clicked.connect(self.volverAtras)
     self.btn_directorio.clicked.connect(self.filechooser)
     self.btn_clasificar.clicked.connect(self.clasificar)
     self.btn_guardar.clicked.connect(self.guardar)
     self.listWidget_valoraciones.doubleClicked.connect(self.opinion)
     self.checkBox_detectarIdioma.stateChanged.connect(
         self.habilitarOpcionesCheckBox)
     self.rutaDirectorio = ""
     self.listaDeFicheros = list()
     self.listaAnalisis = list()
     self.prediccion = list()
     self.titulosGrafico = list()
     self.figure = plt.figure(figsize=(8, 6))
     self.grafico = self.figure.add_subplot(111)
     self.canvas = FigureCanvasQTAgg(self.figure)
     lay = QtWidgets.QVBoxLayout(self.panelEstadistica)
     lay.addWidget(self.canvas)
     self.rellenarModelo()
     self.show()
     self.btn_webscraper.clicked.connect(self.web)
     self.filechooser(ventanaWebScraper.NewApp.flagDirectorio)
     self.filechooser(ventanaSQL.MainWindow.flagDirectorio)
     self.flag = False
     self.btn_directorio.clicked.connect(self.SQL)
     self.flagHilo = True
Beispiel #12
0
    def __init__(self):
        super().__init__()
        # for PyQt embedding
        self.fig = plt.Figure(figsize=(100, 50))
        
        self.canvas = FigureCanvasQTAgg(self.fig)

        self.row =  64# Meshsize
        self.col = 32
        self.fps = 1000 # frame per sec
        self.frn = 10 # frame number of the animation

        self.x = np.linspace(-4,4,self.col)
        self.y = np.linspace(-4,4,self.row)
        self.x, self.y = np.meshgrid(self.x, self.y)
        
        self.zarray = np.zeros([64,32])


        self.ser  = serial.Serial("COM3", baudrate= 2000000, 
            timeout=2.5, 
            parity=serial.PARITY_NONE, 
            bytesize=serial.EIGHTBITS, 
            stopbits=serial.STOPBITS_ONE
            )

        self.initUI()
    def __init__(self):
        self.win = Window(
            windowProps=WindowProps(Title="Diagram View", Width=700, Height=400)
        )
        self.fig = Figure()
        self.canvas = FigureCanvasQTAgg(self.fig)
        self.win.setCentralWidget(self.canvas)
        self.lineManager = LineManager()

        self.axes = self.fig.add_subplot(111)

        self.axes.tick_params(
            axis="both",
            which="major",
            pad=8,
            direction="in",
            top=True,
            right=True,
            width=1.0,
            length=7,
            labelsize=14,
        )

        plt.rc(
            "legend", edgecolor="black", framealpha=1, handlelength=4, fancybox=False
        )

        self.axes.grid(
            linestyle=(0, [1, 10]),
            color=(60 / 255.0, 60 / 255.0, 60 / 255.0),
            linewidth=1,
        )

        self.axes.locator_params(axis="x", nbins=self.xBins)
        self.axes.locator_params(axis="y", nbins=self.yBins)
Beispiel #14
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)
Beispiel #15
0
    def __init__(self):
        """MainWindow constructor"""
        super().__init__()
        self.setupUi(self)
        # Main UI code goes here
        self.model = OttoCycle()
        self.controller = Controller()
        self.view = View()

        # creating a canvas to draw a figure for the rankine cycle
        self.figure = Figure(figsize=(3, 8),
                             tight_layout=True,
                             frameon=True,
                             facecolor='none')
        self.canvas = FigureCanvasQTAgg(self.figure)
        self.ax = self.figure.add_subplot()
        self.main_VerticalLayout.addWidget(self.canvas)

        # Signals and Slots
        self.btn_Calculate.clicked.connect(self.run_backend)
        self.rdo_Metric.toggled.connect(self.set_output)
        self.cmb_graph.currentIndexChanged.connect(self.doPlot)

        # show the form
        self.show()
Beispiel #16
0
 def __init__(self, time_viewer, width, height, dpi):
     from PyQt5 import QtWidgets
     from matplotlib.figure import Figure
     from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
     if time_viewer.separate_canvas:
         parent = None
     else:
         parent = time_viewer.window
     self.fig = Figure(figsize=(width, height), dpi=dpi)
     self.canvas = FigureCanvasQTAgg(self.fig)
     self.axes = self.fig.add_subplot(111)
     self.axes.set(xlabel='Time (sec)', ylabel='Activation (AU)')
     self.canvas.setParent(parent)
     FigureCanvasQTAgg.setSizePolicy(
         self.canvas,
         QtWidgets.QSizePolicy.Expanding,
         QtWidgets.QSizePolicy.Expanding
     )
     FigureCanvasQTAgg.updateGeometry(self.canvas)
     # XXX eventually this should be called in the window resize callback
     tight_layout(fig=self.axes.figure)
     self.time_viewer = time_viewer
     for event in ('button_press', 'motion_notify'):
         self.canvas.mpl_connect(
             event + '_event', getattr(self, 'on_' + event))
Beispiel #17
0
    def ui(self):

        # -------------------------
        # init tests widget
        # -------------------------
        labels = hospitals_df['name'].tolist()
        rapid_tests = hospitals_df['rapid_covid_tests'].tolist()
        lab_tests = hospitals_df['lab_covid_tests'].tolist()
        width = 0.5

        fig = plt.figure(figsize=(3, 5), dpi=100)
        ax = fig.add_subplot(1, 1, 1)
        ax.bar(labels,
               rapid_tests,
               width,
               label='Rapid COVID-19 Test Kits',
               color=LIGHT_BLUE)
        ax.bar(labels,
               lab_tests,
               width,
               label='Lab COVID-19 Test Kits',
               color=DARK_BLUE)

        ax.set_ylabel('Number of COVID-19 Tests')
        ax.set_title('COVID-19 Tests')

        ax.legend()

        self.widget = FigureCanvasQTAgg(fig)
Beispiel #18
0
    def setRow3UI(self):
        # 그래프
        self.fig = Figure()
        self.canvas = FigureCanvasQTAgg(self.fig)
        # 날짜 선택
        self.cbStartDate = QComboBox()
        self.cbStartDate.setFixedWidth(120)
        self.cbStartDate.addItem('---------------')
        self.cbEndDate = QComboBox()
        self.cbEndDate.setFixedWidth(120)
        self.cbEndDate.addItem('---------------')
        pbCalc = QPushButton('계산')
        pbCalc.clicked.connect(self.displayGraph)
        # 배치
        layoutSelectDate = QVBoxLayout()
        layoutSelectDate.addStretch()
        layoutSelectDate.addWidget(self.cbStartDate)
        layoutSelectDate.addWidget(self.cbEndDate)
        layoutSelectDate.addWidget(pbCalc)
        layoutSelectDate.addStretch()

        layoutRow = QHBoxLayout()
        layoutRow.addWidget(self.canvas, stretch=1)
        layoutRow.addLayout(layoutSelectDate)

        self.layoutDialog.addLayout(layoutRow)
Beispiel #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_()
Beispiel #20
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,
                 math_text,
                 width,
                 height,
                 background_color=None,
                 text_color=None,
                 parent=None,
                 **kwargs):
        QWidget.__init__(self, parent, **kwargs)
        l = QVBoxLayout(self)
        l.setContentsMargins(0, 0, 0, 0)
        if background_color is None:
            r, g, b, a = self.palette().base().color().getRgbF()
            background_color = (r, g, b)
        if text_color is None:
            text_color = 'white'
        self.background_color = background_color
        self.text_color = text_color

        self._figure = Figure(edgecolor=background_color,
                              facecolor=background_color)
        self._canvas = FigureCanvasQTAgg(self._figure)
        l.addWidget(self._canvas)

        self._figure.clear()
        self.text = self._figure.suptitle(
            math_text,
            horizontalalignment='center',
            verticalalignment='top',
            size=14,
            color=self.text_color,
        )
        self._canvas.draw()
        self.setFixedSize(width, height)
Beispiel #22
0
    def __init__(self, weather_data, parent=None):
        super(Ten_Days_Plot_Widget, self).__init__(parent)
        self.weather_data = weather_data

        figure = Figure()
        canvas = FigureCanvasQTAgg(figure)

        axis_rain = figure.add_subplot(111)
        axis_rain.set(ylabel='opady[mm]', title='Pogoda na 10 dni')
        axis_rain.xaxis.set_major_locator(plt.MultipleLocator(1))
        axis_rain.set_ylim(0, 20)

        axis_temp = axis_rain.twinx()
        axis_temp.set(ylabel='temperatura [C]')
        axis_temp.yaxis.set_major_locator(plt.MultipleLocator(5))

        x = self.create_x_dataset()
        y_max = self.create_max_temp_dataset()
        y_min = self.create_min_temp_dataset()
        y_rain = self.create_rain_dataset()

        axis_rain.bar(x, y_rain, color='#B3FFFF')
        axis_temp.plot(x, y_max, 'ro-')
        axis_temp.plot(x, y_min, 'bo-')

        axis_temp.set_ylim(axis_temp.get_ylim()[0] - 5,
                           axis_temp.get_ylim()[1] + 5)

        for i in range(0, 10):
            axis_temp.annotate(y_max[i], (x[i], y_max[i] + 1))
            axis_temp.annotate(y_min[i], (x[i], y_min[i] + 1))

        self.layoutVertical = QVBoxLayout(self)
        self.layoutVertical.addWidget(canvas)
Beispiel #23
0
    def __init__(self,parent=None):
        super(MatplotlibWidget, self).__init__(parent)

        self.figure = Figure()
        self.canvas = FigureCanvasQTAgg(self.figure)


        self.axis = self.figure.add_subplot(111)

        self.axis.set_facecolor('None')

        self.axis.spines['top'].set_color('#ffffff')
        self.axis.spines['bottom'].set_color('#ffffff')
        self.axis.spines['left'].set_color('#ffffff')
        self.axis.spines['right'].set_color('#ffffff')
        self.axis.set_ylabel("Amount")
        self.axis.set_xlabel("Sentiment")
        self.axis.tick_params(axis='x', colors='white')
        self.axis.tick_params(axis='y', colors='white')

        self.figure.set_size_inches(3,3)
        self.figure.patch.set_facecolor('None')

        self.layoutVertical = QVBoxLayout(self)  # QVBoxLayout
        self.layoutVertical.addWidget(self.canvas)
Beispiel #24
0
def _try_get_matplotlib_canvas(view):
    """Get the Qt widget from a matplotlib figure."""
    try:
        from matplotlib.pyplot import Figure
        from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
        if isinstance(view, Figure):
            view = FigureCanvasQTAgg(view)
        # Case where the view has a .figure property which is a matplotlib figure.
        elif isinstance(getattr(view, 'figure', None), Figure):
            view = FigureCanvasQTAgg(view.figure)
        elif isinstance(getattr(getattr(view, 'canvas', None), 'figure', None),
                        Figure):
            view = FigureCanvasQTAgg(view.canvas.figure)
    except ImportError as e:  # pragma: no cover
        logger.warning("Import error: %s", e)
    return view
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')
Beispiel #26
0
    def ui(self):

        # -------------------------
        # init ventilators widget
        # -------------------------
        labels = hospitals_df['name'].tolist()
        open_vents = hospitals_df['open_vents'].tolist()
        total_vents = hospitals_df['total_vents'].tolist()
        used_vents = [i - j for i, j in zip(total_vents, open_vents)]
        width = 0.5

        fig = plt.figure(figsize=(5, 5), dpi=100)
        ax = fig.add_subplot(1, 1, 1)
        ax.bar(labels,
               open_vents,
               width,
               label='Open Ventilators',
               color=DARK_BLUE)
        ax.bar(labels,
               used_vents,
               width,
               label='Occupied Ventilators',
               color=LIGHT_GRAY,
               bottom=open_vents)

        ax.set_ylabel('Number of Ventilators')
        ax.set_title('Ventilators')

        ax.legend()

        self.widget = FigureCanvasQTAgg(fig)
Beispiel #27
0
    def __init__(self, weather_data, day_number, parent=None):
        super(Hourly_Plot_Widget, self).__init__(parent)
        self.weather_data = weather_data
        self.day_number = day_number

        figure = Figure()
        canvas = FigureCanvasQTAgg(figure)

        axis_rain = figure.add_subplot(111)
        axis_rain.set(ylabel='opady[mm]', title='Pogoda godzinowa')
        axis_rain.xaxis.set_major_locator(plt.MaxNLocator(10))
        axis_rain.xaxis.set_major_formatter(plt.FormatStrFormatter('%d:00'))
        axis_rain.set_ylim(0, 20)

        axis_temp = axis_rain.twinx()
        axis_temp.set(ylabel='temperatura [C]')
        axis_temp.yaxis.set_major_locator(plt.MultipleLocator(5))

        x = self.create_x_dataset()
        y_temp = self.create_temp_dataset()
        y_rain = self.create_rain_dataset()

        axis_rain.bar(x, y_rain, color='#B3FFFF')
        axis_temp.plot(x, y_temp, 'ro-')

        axis_temp.set_ylim(axis_temp.get_ylim()[0] - 2,
                           axis_temp.get_ylim()[1] + 2)

        for i in range(0, len(x)):
            axis_temp.annotate(y_temp[i], (x[i], y_temp[i] + 1))

        self.layoutVertical = QVBoxLayout(self)
        self.layoutVertical.addWidget(canvas)
Beispiel #28
0
    def __init__(self,
                 workspace_units_to_cm,
                 image_height=645,
                 image_width=860,
                 type=PlotType.LINES):
        super(Scan3DHistoWidget, self).__init__(workspace_units_to_cm)

        self.figure = Figure(figsize=(image_height, image_width))
        self.figure.patch.set_facecolor('white')

        self.axis = self.figure.add_subplot(111, projection='3d')
        self.axis.set_title("")
        self.axis.clear()

        self.colorbar = None

        self.plot_canvas = FigureCanvasQTAgg(self.figure)

        layout = QVBoxLayout()

        layout.addWidget(self.plot_canvas)

        self.setLayout(layout)

        self.xx = None
        self.yy = None
        self.zz = None

        self.title = ""
        self.xlabel = ""
        self.ylabel = ""
        self.zlabel = ""

        self.__type = type
        self.__cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.5)
Beispiel #29
0
 def draw_dig_his_gp(self):
     # 위 그래프
     self.dig_fig = plt.figure(figsize=(20, 20))
     self.gs = self.dig_fig.add_gridspec(1, 1)
     self.dig_ax = [self.dig_fig.add_subplot(self.gs[:, :])]
     self.dig_canv = FigureCanvasQTAgg(self.dig_fig)
     self.EDM_ui.horizontalLayout.addWidget(self.dig_canv)
Beispiel #30
0
    def __init__(self):
        global popRange
        self.data = np.zeros(shape=(0, 6))
        self.current_census = core.census(popRange.currentpop)
        self.fig = Figure(figsize=[12, 6])
        self.canvas = FigureCanvasQTAgg(self.fig)
        self.canvas.setWindowTitle('Time evolution')

        self.axes = list()
        self.axes.append(self.fig.add_subplot(121))
        self.axes.append(self.fig.add_subplot(222))
        self.axes.append(self.fig.add_subplot(224))

        self.im = pop_image(self.axes[0], popRange.currentpop)
        self.ln = timeSeriesLines(self.axes[1], self.data)
        self.ln.append(*self.axes[2].plot([], [], lw=2))
        self.axes[1].set_ylim(0.0, 1.0)
        tau_i = r'$\tau_{i}$=%i' % core.Ti
        tau_r = r'$\tau_{r}$=%i' % core.Tr
        nbrs = f'nbrs={len(popRange.nbrs)}'
        self.axes[1].set_title(f'Time Series\t{tau_i}\t{tau_r}\t{nbrs}')
        self.axes[1].legend(loc='upper right')
        self.axes[2].set_ylim(-1, 3)
        ham_dist_phase = r'|$\frac{1}{N}\Sigma e^{i\phi}$|'
        self.axes[2].set_title(f'Order Parameter = {ham_dist_phase}')