当前位置: 首页>>代码示例>>Python>>正文


Python FigureCanvasQTAgg.setMaximumSize方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setMaximumSize方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.setMaximumSize方法的具体用法?Python FigureCanvasQTAgg.setMaximumSize怎么用?Python FigureCanvasQTAgg.setMaximumSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg的用法示例。


在下文中一共展示了FigureCanvasQTAgg.setMaximumSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Airconics_Viewgrid

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMaximumSize [as 别名]

#.........这里部分代码省略.........
        data_box.addWidget(self._data_canvas)

        data_group.setLayout(data_box)

        grid.addWidget(data_group, 0, 1)


        self.select_button = QtGui.QPushButton('Select', self)

        grid.addWidget(self.select_button, 1, 0, 1, 2)


        self.select_clicked.connect(self.Evolve)

        self._Topology.Display(self.viewer._display)

    @property
    def Topology(self):
        return self._Topology

    @Topology.setter
    def Topology(self, newTopology):
        self._Topology = newTopology
        self._Topology.Display(self.viewer._display)
        self.viewer._display.FitAll()

    # @QtCore.pyqtSlot()
    # def onSelectButtonClick(self):
    #     Airconics_Viewgrid.select_clicked.emit()

    @QtCore.pyqtSlot()
    def Evolve(self):
        self.viewer._display.EraseAll()
        self.Topology.Display(self.viewer._display)

        Nvars = len(self.data_labels)

        # This initialises some data in the radar plot: remove this later!
        data = np.random.random(Nvars)

        self._ax.plot(self.radar_factory, data, color=self.color)
        self._ax.fill(self.radar_factory, data, facecolor=self.color,
                      alpha=0.25)

        self._data_canvas.repaint()
        self._ax.redraw_in_frame()

    def InitDataCanvas(self):
        """Initialises a radar chart in self._data_canvas to be embedded in
        the parent viewer widget

        The radar chart contains the labels defined at the class level via
        self.data_labels.
        """
        # Labels
        # labels = []
        # outputs = []

        # data_group = QtGui.QGroupBox("Estimated Performance Metrics")
        # data_gridlayout = QtGui.QVBoxLayout(data_group)

        # for i, lbl_string in enumerate(self.data_box_labels):
        #     label = QtGui.QLabel(lbl_string)
        #     labels.append(label)

        #     # output = QtGui.QLineEdit("Nil")
        #     # output.setReadOnly(True)
        #     # outputs.append(output)

        #     data_gridlayout.addWidget(label)
        #     # data_gridlayout.addWidget(output, i, 1)

        # data_group.setLayout(data_gridlayout)
        Nvars = len(self.data_labels)
        # Nvars = len(self.data_labels)
        self.radar_factory = radar_factory(Nvars, frame='polygon')

        # This initialises some data in the radar plot: remove this later!
        data = np.random.random(Nvars)

        self._fig = plt.figure(facecolor="white")
        self._ax = self._fig.add_subplot(111, projection='radar')

        self._ax.set_rgrids([0.2, 0.4, 0.6, 0.8])
        self._ax.set_rmin(0.)
        self._ax.set_rmax(1.)

        self._ax.plot(self.radar_factory, data, color=self.color)
        self._ax.fill(self.radar_factory, data, facecolor=self.color,
                      alpha=0.25)
        self._ax.set_varlabels(self.data_labels)

        # plt.tight_layout()

        self._data_canvas = FigureCanvas(self._fig)
        self._data_canvas.setParent(self)
        self._data_canvas.setFocusPolicy(QtCore.Qt.StrongFocus)

        # self._data_canvas.setMinimumSize(200, 200)
        self._data_canvas.setMaximumSize(200, 200)
开发者ID:p-chambers,项目名称:occ_airconics,代码行数:104,代码来源:configuration_app.py

示例2: Window

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMaximumSize [as 别名]
class Window(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.shot = None  #opened shot
        self.folder_name = ''  #folder to search for shots
        self.current_num = 0  #current diagram
        self.currently_selected = None  #selected point plot
        self.selected_points = OrderedSet()  #point to be added
        self.current_point = None  #plot of current point
        self.overall_selected = None  #points added to selected list
        #super(Window, self).__init__(parent)
        # a figure instance to plot on
        self.figure = plt.figure()

        # this is the Canvas Widget that displays the `figure`
        # it takes the `figure` instance as a parameter to __init__
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setParent(parent)
        self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.canvas.setFocus()
        self.canvas.setMinimumSize(500, 0)
        self.canvas.mpl_connect('pick_event', self.on_pick)
        self.canvas.mpl_connect('motion_notify_event', self.on_move)
        self.canvas.hide()

        # this is the Navigation widget
        # it takes the Canvas widget and a pa rent
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        # Show files widget
        self.files = QtGui.QListWidget()
        self.files.itemDoubleClicked.connect(self.select_file)
        self.files.setMaximumSize(200, 100000)
        self.files.setMinimumSize(100, 0)
        self.files.hide()

        # Show selected points
        self.points = ThumbListWidget(self)
        #self.points.itemDoubleClicked.connect(self.unselect_point)
        self.points.itemClicked.connect(self.points_clicked)
        self.points.itemDoubleClicked.connect(self.points_doubleclicked)
        self.points.setMaximumSize(200, 100000)
        self.points.setMinimumSize(100, 0)
        self.points.hide()

        #Show diagram widget
        self.diagrams = QtGui.QListWidget()
        self.diagrams.itemClicked.connect(self.select_item)
        self.diagrams.setMaximumSize(250, 100000)
        self.diagrams.setMinimumSize(190, 0)
        self.diagrams.hide()

        #save result button
        self.save_button = QtGui.QPushButton('Add time point', self)
        self.save_button.clicked.connect(self.add_time)
        self.save_button.hide()

        #filter menu
        self.filters_button = QtGui.QPushButton('Manage filters', self)
        self.filters_button.clicked.connect(self.show_filters)
        self.filters_button.hide()
        self.filters = OrderedDict
        self.read_filters()


        #diagramms
        self.bottom_layout = QtGui.QGridLayout()
        self.diagrams_figure = plt.figure()
        self.diagrams_canvas = FigureCanvas(self.diagrams_figure)
        self.diagrams_canvas.setParent(parent)
        self.diagrams_canvas.setMinimumSize(250, 250)
        self.diagrams_canvas.setMaximumSize(500, 500)
        self.diagrams_toolbar = NavigationToolbar(self.diagrams_canvas, self)
        self.diagrams_toolbar.setMaximumWidth(250)
        self.diagrams_ax = self.diagrams_figure.add_subplot(111)
        self.diagrams_ax.set_ylim(ymin=0)
        self.diagrams_ax.set_xlim(xmin=0)
        self.diagrams_canvas.draw()

        self.enlargre_button = QtGui.QPushButton('Enlarge diagram', self)
        self.enlargre_button.clicked.connect(self.enlarge_diagram)

        self.bottom_layout.addWidget(self.diagrams_toolbar, 0, 2)
        self.bottom_layout.addWidget(self.diagrams_canvas, 1, 2, QtCore.Qt.AlignRight)
        self.bottom_layout.addWidget(self.enlargre_button, 0, 1)

        # set the layout
        self.layout = QtGui.QGridLayout()
        self.layout.addWidget(self.filters_button, 0, 1)
        self.layout.addWidget(self.toolbar, 0, 2)
        self.layout.addWidget(self.canvas, 1, 2)
        self.layout.addWidget(self.diagrams, 1, 1)
        self.layout.addWidget(self.files, 1, 0)
        self.layout.addWidget(self.points, 1, 3)
        self.layout.addWidget(self.save_button, 0, 3)
        self.layout.addLayout(self.bottom_layout, 2, 2)
        self.setLayout(self.layout)


#.........这里部分代码省略.........
开发者ID:wimag,项目名称:shtty-viewer,代码行数:103,代码来源:main.py

示例3: PlotGenerator

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMaximumSize [as 别名]
class PlotGenerator(QFrame):

    def __init__(self, plot_path, plot_config_path):
        QFrame.__init__(self)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.plot_figure = PlotFigure()
        self.canvas = FigureCanvas(self.plot_figure.getFigure())
        self.canvas.setParent(self)
        self.canvas.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

        size = QSize(297*2, 210*2) # A4 aspectratio
        self.canvas.setMaximumSize(size)
        self.canvas.setMinimumSize(size)
        self.setMaximumSize(size)
        self.setMinimumSize(size)

        self.popup = Popup(self)
        self.plot_config_loader = PlotSettingsLoader()
        self.plot_settings = PlotSettings()
        self.plot_settings.setPlotPath(plot_path)
        self.plot_settings.setPlotConfigPath(plot_config_path)
        self.connect(self.popup, SIGNAL('updateProgress(int)'), self.updateProgress)


        self.plot_context_data_fetcher = PlotContextDataFetcher()
        self.plot_context_data_fetcher.initialize(self.plot_context_data_fetcher.getModel())
        self.plot_data_fetcher = PlotDataFetcher()
        self.plot_data_fetcher.initialize(self.plot_data_fetcher.getModel())

    def updateProgress(self, progress = 1):
        value = self.popup.progress_bar.value()
        self.popup.progress_bar.setValue(value + progress)

    def saveAll(self):
        self.popup.show()

        context_data = self.plot_context_data_fetcher.getFromModel()

        save_list = []
        count = 0
        for parameter in context_data.parameters:
            pt = parameter.type

            if pt == SummaryModel.TYPE or pt == KeywordModel.TYPE or pt == enums.obs_impl_type.FIELD_OBS:
                save_list.append(parameter)
                parameter.setUserData({'state' : enums.ert_state_enum.FORECAST})

                if pt == KeywordModel.TYPE:
                    choices = context_data.key_index_list[parameter.name]
                    parameter.getUserData()['key_index_choices'] = choices
                    count += len(choices)
                else:
                    count += 1


        self.popup.progress_bar.setMaximum(count)

        for parameter in save_list:
            if parameter.type == KeywordModel.TYPE:
                for choice in parameter.getUserData()['key_index_choices']:
                    self.plot_data_fetcher.setParameter(parameter, context_data)
                    parameter.getUserData()['key_index'] = choice # because setParameter overwrites this value
                    self.plot_data_fetcher.fetchContent()
                    self.savePlot(self.plot_data_fetcher.data)
            else:
                self.plot_data_fetcher.setParameter(parameter, context_data)
                self.plot_data_fetcher.fetchContent()
                self.savePlot(self.plot_data_fetcher.data)

        self.popup.ok_button.setEnabled(True)

    def save(self, plot_data):
        self.popup.show()

        self.popup.progress_bar.setMaximum(1)

        self.savePlot(plot_data)
        self.popup.ok_button.setEnabled(True)


    def savePlot(self, plot_data):
        generated_plot = self.generatePlot(plot_data)
        if generated_plot:
            self.savePlotToFile(plot_data.getSaveName())
        self.popup.emit(SIGNAL('updateProgress(int)'), 1)

    def generatePlot(self, plot_data):
        name = plot_data.getSaveName()
        load_success = self.plot_config_loader.load(name, self.plot_settings)

        if load_success:
            self.plot_figure.drawPlot(plot_data, self.plot_settings)
            self.canvas.draw()

        return load_success

    def savePlotToFile(self, filename):
        """Save the plot visible in the figure."""
        plot_path = self.plot_settings.getPlotPath()
#.........这里部分代码省略.........
开发者ID:akva2,项目名称:ResInsight,代码行数:103,代码来源:plotgenerator.py

示例4: Window

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMaximumSize [as 别名]
class Window(QtGui.QMainWindow):
    r""" A mainwindow object for the GUI display. Inherits from QMainWindow."""

    def __init__(self):
        super(Window, self).__init__()
        self.interface()

    def interface(self):
        r""" Contains the main window interface generation functionality. Commented where needed."""

        # Get the screen width and height and set the main window to that size
        screen = QtGui.QDesktopWidget().screenGeometry()
        self.setGeometry(0, 0, 800, screen.height())
        self.setMaximumSize(QtCore.QSize(800, 2000))

        # Set the window title and icon
        self.setWindowTitle("WAVE: Weather Analysis and Visualization Environment")
        self.setWindowIcon(QtGui.QIcon('./img/wave_64px.png'))

        # Import the stylesheet for this window and set it to the window
        stylesheet = "css/MainWindow.css"
        with open(stylesheet, "r") as ssh:
            self.setStyleSheet(ssh.read())
        self.setAutoFillBackground(True)
        self.setBackgroundRole(QtGui.QPalette.Highlight)

        # Create actions for menus and toolbar
        exit_action = QtGui.QAction(QtGui.QIcon('./img/exit_64px.png'), 'Exit', self)
        exit_action.setShortcut('Ctrl+Q')
        exit_action.setStatusTip('Exit application')
        exit_action.triggered.connect(self.close)
        clear_action = QtGui.QAction(QtGui.QIcon('./img/clear_64px.png'), 'Clear the display', self)
        clear_action.setShortcut('Ctrl+C')
        clear_action.setStatusTip('Clear the display')
        clear_action.triggered.connect(self.clear_canvas)
        skewt_action = QtGui.QAction(QtGui.QIcon('./img/skewt_64px.png'), 'Open the skew-T dialog', self)
        skewt_action.setShortcut('Ctrl+S')
        skewt_action.setStatusTip('Open the skew-T dialog')
        skewt_action.triggered.connect(self.skewt_dialog)
        radar_action = QtGui.QAction(QtGui.QIcon('./img/radar_64px.png'), 'Radar', self)
        radar_action.setShortcut('Ctrl+R')
        radar_action.setStatusTip('Open Radar Dialog Box')
        radar_action.triggered.connect(self.radar_dialog)

        # Create the top menubar, setting native to false (for OS) and add actions to the menus
        menubar = self.menuBar()
        menubar.setNativeMenuBar(False)
        filemenu = menubar.addMenu('&File')
        editmenu = menubar.addMenu('&Edit')
        helpmenu = menubar.addMenu('&Help')
        filemenu.addAction(exit_action)

        # Create the toolbar, place it on the left of the GUI and add actions to toolbar
        left_tb = QtGui.QToolBar()
        self.addToolBar(QtCore.Qt.LeftToolBarArea, left_tb)
        left_tb.setMovable(False)
        left_tb.addAction(clear_action)
        left_tb.addAction(skewt_action)
        left_tb.addAction(radar_action)
        self.setIconSize(QtCore.QSize(30, 30))

        # Create the toolbar, place it on the left of the GUI and add actions to toolbar
        right_tb = QtGui.QToolBar()
        self.addToolBar(QtCore.Qt.RightToolBarArea, right_tb)
        right_tb.setMovable(False)
        right_tb.addAction(clear_action)
        right_tb.addAction(skewt_action)
        right_tb.addAction(radar_action)

        # Create the status bar with a default display
        self.statusBar().showMessage('Ready')

        # Figure and canvas widgets that display the figure in the GUI
        self.figure = plt.figure(facecolor='#2B2B2B')
        self.canvas = FigureCanvas(self.figure)

        # Add subclassed matplotlib navbar to GUI
        # spacer widgets for left and right of buttons
        left_spacer = QtGui.QWidget()
        left_spacer.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        right_spacer = QtGui.QWidget()
        right_spacer.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        self.mpltb = QtGui.QToolBar()
        self.mpltb.addWidget(left_spacer)
        self.mpltb.addWidget(MplToolbar(self.canvas, self))
        self.mpltb.addWidget(right_spacer)
        self.mpltb.setMovable(False)
        self.addToolBar(QtCore.Qt.TopToolBarArea, self.mpltb)

        # Set the figure as the central widget and show the GUI
        self.setCentralWidget(self.canvas)
        self.show()

    def skewt_dialog(self):
        r""" When the toolbar icon for the Skew-T dialog is clicked, this function is executed. Creates an instance of
        the SkewTDialog object which is the dialog box. If the submit button on the dialog is clicked, get the user
        inputted values and pass them into the sounding retrieval call (DataAccessor.get_sounding) to fetch the data.
        Finally, plot the returned data via self.plot.

        Args:
#.........这里部分代码省略.........
开发者ID:Unidata,项目名称:Wave,代码行数:103,代码来源:mainwindow.py


注:本文中的matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setMaximumSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。