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


Python NavigationToolbar2QTAgg.setSizePolicy方法代码示例

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


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

示例1: PlotWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import setSizePolicy [as 别名]
class PlotWidget(QWidget):
    def __init__(self, parent=None):
        super(PlotWidget, self).__init__(parent)
        # create widgets
        self.canvas = PlotCanvas()
        self.toolbar = NavigationToolbar(self.canvas, self.canvas)
        self.toolbar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        vbox = QVBoxLayout()
        vbox.addWidget(self.toolbar)
        vbox.addWidget(self.canvas)
        self.setLayout(vbox)

    def draw_curves (self, curve_names, data):
        self.canvas.axes.clear()
        self.canvas.axes.grid(True, color='gray')
        for name in curve_names:
            xdata, ydata = data[name]
            self.canvas.axes.plot(xdata, ydata, 'o-', label=name)[0]
        self.update_legend()
        self.canvas.draw()

    def update_legend(self):
        handles, labels = self.canvas.axes.get_legend_handles_labels()
        self.canvas.axes.legend(handles, labels, loc='upper left')
开发者ID:aaravrav142,项目名称:rqt_joint_trajectory_plot,代码行数:26,代码来源:plot_widget.py

示例2: CalibrationWindow

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import setSizePolicy [as 别名]
class CalibrationWindow(QtGui.QMainWindow):
    """
    Order on the layers in the right tab

    mask > data > massif > solid_angle
    """
    ZORDER = {"contour":5,
              "point": 4,
              "mask": 3,
              "data": 2,
              "massif": 1,
              "solidangle": 0,
              }
    INTERPOLATION = "nearest"
    ORIGIN = "lower"

    def __init__(self,):
        QtGui.QWidget.__init__(self)
        uic.loadUi("calibration_main.ui", self)
        self.connect(self.actionAbout_calibrate, SIGNAL("triggered()"), self.on_about)
        self.dpi = 100
        self.fig = self.canvas = self.mpl_toolbar = self.pix_coords_label = None
        self.axes = None
        # ar is for artists: plot, images or labels...
        self.ar_data = self.ar_mask = self.ar_massif = self.ar_contour = self.ar_solidangle = self.ar_points = None
        self.data = self.massif = self.solid_angle = self.mask = None
        self.display_checks = {}
        self.display_widget = None
        self.input_widget = None
        self.build_right_frame()
        self.build_input_tab()

    def on_about(self):
        msg = [__doc__,
               "",
               "Version date: \t%s" % __date__,
               "PyFAI version: \t%s" % pyFAI.version,
               "FabIO version: \t%s" % fabio.version,
               "Author: \t\t%s" % __author__,
               "Copyright: \t\t%s" % __copyright__,
               "License: \t\t%s" % __license__]
        QtGui.QMessageBox.about(self, "About calibrate", os.linesep.join(msg))

    def build_right_frame(self):
        "build the right frame that contains matplotlib widgets"

        self.fig = Figure(dpi=self.dpi)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.image_frame)

        # Create the navigation toolbar, tied to the canvas
        self.mpl_toolbar = NavigationToolbar(self.canvas, self.image_frame, coordinates=False)

        self.axes = self.fig.add_subplot(111)
        self.axes.set_visible(False)
        # Bind the 'pick' event for clicking on one of the bars
        self.canvas.mpl_connect('motion_notify_event', self.on_pick)

        self.pix_coords_label = QtGui.QLabel("x= None , y= None , i= None ", self)
        self.mpl_toolbar.addWidget(self.pix_coords_label)

        self.display_widget = uic.loadUi("display_widget.ui")

        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.mpl_toolbar, alignment=QtCore.Qt.AlignTop)
        vbox.addWidget(self.canvas)
        vbox.addWidget(self.display_widget, alignment=QtCore.Qt.AlignBottom)
        self.image_frame.setLayout(vbox)

        # Enforce the size Policy of sub-widgets
        pol = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        self.mpl_toolbar.setSizePolicy(pol)
        self.display_widget.setSizePolicy(pol)
        self.canvas.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))

        # few signals about those new widgets:
        self.display_checks = {"data": self.display_widget.show_data,
                               "mask": self.display_widget.show_mask,
                               "massif": self.display_widget.show_massif,
                               "points": self.display_widget.show_points,
                               "contour": self.display_widget.show_contour,
                               "solidangle": self.display_widget.show_solidangle}
        for v in self.display_checks.itervalues():
            self.connect(v, SIGNAL("stateChanged(int)"), self.toggle_show)

    def build_input_tab(self):
        self.input_widget = InputWidget()
        self.scrollArea_input.setWidget(self.input_widget)

#        area->setWidget(widget);
#        box = QtGui.QHBoxLayout()
#        box.addWidget(self.input_widget)
#        self.input_frame.setLayout(box)
#        self.input_widget.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
#        self.input_frame.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))


    def on_pick(self, event):
        if event.inaxes and self.data is not None and self.data.any():
            if int(event.xdata) <= self.data.shape[1] and int(event.ydata) <= self.data.shape[0]:
#.........这里部分代码省略.........
开发者ID:kif,项目名称:UPBL09a,代码行数:103,代码来源:calibration_view.py


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