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


Python NavigationToolbar2QT.setSizePolicy方法代码示例

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


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

示例1: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import setSizePolicy [as 别名]
    def __init__(self, parent=None):
        super(ExperimentResultWidget, self).__init__()

        self.tab = QtGui.QTabWidget()

        # Figure 1
        figure = plt.figure()
        canvas = FigureCanvas(figure)
        canvas.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
        canvas.setMinimumSize(50, 50)
        toolbar = NavigationToolbar(canvas, self)
        toolbar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

        widget = QtGui.QWidget()
        layout = QtGui.QVBoxLayout()
        layout.addWidget(canvas)
        layout.addWidget(toolbar)
        widget.setLayout(layout)
        self.tab.addTab(widget, 'Results')
        self.plot = figure

        # Tab 1
        self.trackCountsTable = QtGui.QTableWidget()
        self.tab.addTab(self.trackCountsTable, 'Track Counts')

        # Tab 2
        self.networkOverviewTable = QtGui.QTableWidget()
        self.tab.addTab(self.networkOverviewTable, 'Network Overview')

        # Tab 3
        self.trackTerminationTable = QtGui.QTableWidget()
        self.trackInitiationTable = QtGui.QTableWidget()

        widget = QtGui.QWidget()
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.trackTerminationTable)
        layout.addWidget(self.trackInitiationTable)
        widget.setLayout(layout)
        self.tab.addTab(widget, 'Track Fragmentation')

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.tab)
        self.setLayout(layout)
开发者ID:amarallab,项目名称:waldo,代码行数:45,代码来源:widgets.py

示例2: PandasMplWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import setSizePolicy [as 别名]
class PandasMplWidget(QtGui.QWidget):

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.pmc = PandasMplCanvas(width=2, height=2, dpi=100)
        self.toolbar = NavigationToolbar(self.pmc.figure.canvas, self)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHeightForWidth(True)
        self.toolbar.setSizePolicy(sizePolicy)

        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.pmc)
        vbox.addWidget(self.toolbar)
        self.setLayout(vbox)

    def get_figure_canvas(self):
        return self.pmc

    def plot(self, data):
        self.pmc.plot_data_frame(data)
开发者ID:samueljackson92,项目名称:NDImage,代码行数:23,代码来源:mpl_canvas.py

示例3: ThresholdCacheWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import setSizePolicy [as 别名]
class ThresholdCacheWidget(QtGui.QWidget):
    def __init__(self, on_changed_ev, parent=None):
        super(ThresholdCacheWidget, self).__init__()
        self.on_changed_ev = on_changed_ev
        self.parent = parent

        self.histogram_figure = plt.figure()
        self.histogram_canvas = FigureCanvas(self.histogram_figure)
        self.histogram_canvas.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.histogram_canvas.setMinimumSize(50, 50)
        self.histogram_toolbar = NavigationToolbar(self.histogram_canvas, parent)
        self.histogram_toolbar.coordinates = False
        self.histogram_toolbar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

        self.image_figure = plt.figure()
        self.image_canvas = FigureCanvas(self.image_figure)
        self.image_canvas.setMinimumSize(50, 50)
        self.image_canvas.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.image_toolbar = NavigationToolbar(self.image_canvas, parent)
        self.image_toolbar.coordinates = False
        self.image_toolbar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

        gs = grd.GridSpec(3, 1)
        self.ax_objects = self.histogram_figure.add_subplot(gs[0, 0])
        self.ax_area = self.histogram_figure.add_subplot(gs[1, 0], sharex=self.ax_objects)
        self.ax_image = self.image_figure.add_subplot(111)

        layout = QtGui.QGridLayout()

        q1 = QtGui.QLabel("<b>Choose Threshold</b>")
        layout.addWidget(q1, 0, 0, 1, 1)
        layout.addWidget(QtGui.QLabel("Click on either graph to pick a threshold value"), 1, 0, 1, 1)
        layout.addWidget(self.histogram_canvas, 3, 0, 1, 1)
        layout.addWidget(self.histogram_toolbar, 4, 0, 1, 1)

        self.roiSelectorBar = ROISelectorBar(self.image_figure, self.ax_image)
        self.roiSelectorBar.roi_changed.connect(self.roiSelectorBar_roi_changed)

        self.calibrationBar = CalibrationBar(10, self.image_figure, self.ax_image)
        self.calibrationBar.calibration_changed.connect(self.calibrationBar_calibration_changed)

        q2 = QtGui.QLabel("<b>Define Region of Interest</b>")
        layout.addWidget(q2, 0, 1, 1, 1)
        layout.addWidget(self.roiSelectorBar, 1, 1, 1, 1)
        layout.addWidget(self.calibrationBar, 2, 1, 1, 1)
        layout.addWidget(self.image_canvas, 3, 1, 1, 1)
        layout.addWidget(self.image_toolbar, 4, 1, 1, 1)
        self.setLayout(layout)

        self.histogram_figure.canvas.mpl_connect('button_press_event', self.on_histogram_button_pressed)
        # self.image_figure.canvas.mpl_connect('button_press_event', self.on_image_button_pressed)

        self.thresholds = []

    @staticmethod
    def create_background(impaths):
        """
        create a background image for background subtraction.
        The background image is the maximum pixel values from three grayscale images.

        params
        ---------
        impaths: (list)
           this is a sorted list containing paths to all the image files from one recording.
        """
        if len(impaths) == 0:
            return None
        first = mpimg.imread(impaths[0])
        mid = mpimg.imread(impaths[int(len(impaths)/2)])
        last = mpimg.imread(impaths[-1])
        return np.maximum(np.maximum(first, mid), last)

    def clear_experiment_data(self):
        self.roiSelectorBar.clear_roi()
        self.threshold = 0.0005

    def load_experiment(self, experiment):
        self.experiment = experiment
        self.annotation_filename = str(paths.threshold_data(experiment.id))
        try:
            with open(self.annotation_filename, "rt") as f:
                data = json.loads(f.read())
            # self.circle = None
            self.roiSelectorBar.json_to_data(data)
            self.threshold = data.get('threshold', 0.0005)
        except IOError as ex:
            self.clear_experiment_data()

        self.calibration_filename = str(paths.calibration_data(experiment.id))
        try:
            with open(self.calibration_filename, "rt") as f:
                data = json.loads(f.read())
            self.calibrationBar.json_to_data(data)
        except IOError as ex:
            self.calibrationBar.clear_calibration()

        times, impaths = zip(*sorted(experiment.image_files.items()))
        impaths = [str(s) for s in impaths]

        if times is not None and len(times) > 0:
#.........这里部分代码省略.........
开发者ID:amarallab,项目名称:waldo,代码行数:103,代码来源:widgets.py


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