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


Python PlotWidget.plot方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
    def __init__(self, parent=None):
        
        super(Form, self).__init__()

        self.tab = QTabWidget()

        # Add demo data for tab 1
        x = np.random.normal(size=1000)
        y = np.random.normal(size=1000)
        plot1 = PlotWidget()
        plot1.plot(x, y, pen=None, symbol='o')

        self.tab.insertTab(0, plot1, "random")

        # Add demo data for tab 2
        x = np.linspace(0, 6*np.pi, 1000)
        y = np.sin(x)
        plot2 = PlotWidget()
        plot2.plot(x, y)

        self.tab.insertTab(1, plot2, "sinus")

        self.main_window = QMainWindow()
        self.main_window.setCentralWidget(self.tab)
        self.main_window.show()

        # Force the window to stay on top
        self.setWindowFlags(Qt.WindowStaysOnTopHint)
开发者ID:frruit,项目名称:udemy_pyqt,代码行数:30,代码来源:pyqtgraph_embedded.py

示例2: Example

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
class Example(QtGui.QWidget):
    
    def __init__(self):
        super(Example, self).__init__()        
        self.initUI()


        self.current_y = 0

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.update_plot)
        self.timer.setInterval(1000/FREQ)
        self.timer.start()
        
        
    def initUI(self):
        
        self.setGeometry(300, 300, 1000, 1000)
        self.setWindowTitle('Icon')
        self.setWindowIcon(QtGui.QIcon('web.png'))



        self.plot = PlotWidget(self, axisItems={'bottom': TimeAxisItem(orientation='bottom')})
        self.plot.resize(900, 900)
        self.curve = self.plot.plot(x, ys[0])
        #self.curve.attach(self.plot)
        self.show()

    def update_plot(self):
        self.curve.setData(x, ys[self.current_y])
        self.current_y = (self.current_y + 1) % YS
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:34,代码来源:test_pyqtgraph.py

示例3: Example

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
class Example(QtGui.QWidget):
    def __init__(self):
        super(Example, self).__init__()        
        self.setGeometry(300, 300, 400, 400)
        self.plot = PlotWidget(self, axisItems={'bottom': TimeAxisItem(orientation='bottom')})
        self.plot.resize(300, 300)
        self.curve = self.plot.plot(np.linspace(0, 10, 100), np.random.random(100))
        self.show()
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:10,代码来源:double_axis.py

示例4: draw_right_part

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
    def draw_right_part(self):
        rightPart = QtGui.QVBoxLayout()

        from pyqtgraph import PlotWidget
        pl = PlotWidget()
        self.plotU = pl.plot(pen=(255, 0, 0))

        rightPart.addWidget(pl)

        self.menuLayout = QtGui.QGridLayout()

        temp = QtGui.QHBoxLayout()
        templabel = QtGui.QLabel(u'  COM порт №    ')
        self.text_COM_number = QtGui.QLineEdit()
        temp.addWidget(templabel)
        temp.addWidget(self.text_COM_number)

        self.button_setCOM = QtGui.QPushButton(u'Выбрать')
        self.button_setCOM.clicked.connect(self.button_setCOM_pressed)
        temp.addWidget(self.button_setCOM)
        temp.addStretch(1)

        #self.menuLayout.addWidget(self.button_setCOM, 0, 1)#, alignment=1)
        self.menuLayout.addLayout(temp,0,0)

        temp = QtGui.QHBoxLayout()
        self.button_hardware = QtGui.QPushButton(u'Старт платформы')
        self.button_hardware.clicked.connect(self.button_hardware_pressed)
        temp.addWidget(self.button_hardware)
        #self.menuLayout.addWidget(self.button_hardware, 1, 0)#, alignment=1)

        self.button_watch = QtGui.QPushButton(u'Начать просмотр')
        self.button_watch.clicked.connect(self.button_watch_pressed)
        temp.addWidget(self.button_watch)

        self.button_record = QtGui.QPushButton(u' Начать запись ')
        self.button_record.clicked.connect(self.button_record_pressed)
        temp.addWidget(self.button_record)
        temp.addStretch(1)

        self.menuLayout.addLayout(temp, 1,0)#Widget(self.button_watch, 1, 1)#, alignment=1)

        self.menuLayout.addLayout(self.build_parameters_menu(), 2, 0)

        temp = QtGui.QHBoxLayout()
        temp.insertSpacing(-1, 10)
        self.string_message = QtGui.QLineEdit()
        temp.addWidget(self.string_message)

        self.button_send_string = QtGui.QPushButton(u'Отправить строку')
        self.button_send_string.clicked.connect(self.button_send_string_pressed)
        temp.addWidget(self.button_send_string)
        temp.insertStretch(-1, 1)
        self.menuLayout.addLayout(temp, 3, 0)#, alignment=1)

        rightPart.addLayout(self.menuLayout)

        self.parts[1].setLayout(rightPart)
开发者ID:zimka,项目名称:project_platform,代码行数:60,代码来源:main.py

示例5: RealtimePlotWidget

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
class RealtimePlotWidget(QWidget):
    COLORS = [Qt.red, Qt.blue, Qt.green, Qt.magenta, Qt.cyan,
              Qt.darkRed, Qt.darkBlue, Qt.darkGreen, Qt.darkYellow, Qt.gray]

    def __init__(self, parent=None):
        super(RealtimePlotWidget, self).__init__(parent)
        self._plot_widget = PlotWidget()
        self._plot_widget.setBackground((0, 0, 0))
        self._plot_widget.addLegend()
        self._plot_widget.showButtons()
        self._plot_widget.enableAutoRange()
        self._plot_widget.showGrid(x=True, y=True, alpha=0.2)
        vbox = QVBoxLayout()
        vbox.addWidget(self._plot_widget)
        self.setLayout(vbox)

        self._color_index = 0
        self._curves = {}

    def add_curve(self, curve_id, curve_name, data_x=[], data_y=[]):
        color = QColor(self.COLORS[self._color_index % len(self.COLORS)])
        self._color_index += 1
        pen = mkPen(color, width=1)
        plot = self._plot_widget.plot(name=curve_name, pen=pen)
        data_x = numpy.array(data_x)
        data_y = numpy.array(data_y)
        self._curves[curve_id] = {'x': data_x, 'y': data_y, 'plot': plot}

    def remove_curve(self, curve_id):
        curve_id = str(curve_id)
        if curve_id in self._curves:
            self._plot_widget.removeItem(self._curves[curve_id]['plot'])
            del self._curves[curve_id]

    def set_x_range(self, left, right):
        self._plot_widget.setRange(xRange=(left, right))

    def update_values(self, curve_id, x, y):
        curve = self._curves[curve_id]
        curve['x'] = numpy.append(curve['x'], x)
        curve['y'] = numpy.append(curve['y'], y)

    def redraw(self):
        for curve in self._curves.values():
            if len(curve['x']):
                curve['plot'].setData(curve['x'], curve['y'])

    def lazy_redraw(self, period):
        timestamp = time.time()
        if not hasattr(self, '_prev_lazy_redraw'):
            self._prev_lazy_redraw = 0.0
        if timestamp - self._prev_lazy_redraw > period:
            self._prev_lazy_redraw = timestamp
            self.redraw()
开发者ID:Aerobota,项目名称:sapog,代码行数:56,代码来源:plot_widget.py

示例6: __init__

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
 def __init__(self,channel,trace,units):
     QtGui.QDialog.__init__(self)
     layout = QtGui.QVBoxLayout()
     self.setLayout(layout)
     plot_widget = PlotWidget(
         title='%s trace' % channel, 
         labels={'left':units}
                 )
     layout.addWidget(plot_widget)
     plot = plot_widget.plot(trace)
     self.plot = plot
     self.trace = trace
开发者ID:creilly,项目名称:sitzlabrad,代码行数:14,代码来源:voltmetergui.py

示例7: Example

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
class Example(QtGui.QWidget):
    
    def __init__(self):
        super(Example, self).__init__()        
        self.initUI()


        self.current_y = 0

        #self.timer = QtCore.QTimer()
        #self.timer.timeout.connect(self.update_plot)
        #self.timer.setInterval(1000/FREQ)
        #self.timer.start()
        
        
    def initUI(self):
        
        self.setGeometry(300, 300, 1000, 1000)
        self.setWindowTitle('Icon')
        self.setWindowIcon(QtGui.QIcon('web.png'))



        self.plot = PlotWidget(self)
        self.plot.resize(900, 900)
        self.curves = []
        for x, y in zip(chunkedx, chunkedy):
            print('plot', len(x), len(y))
            self.curves.append(self.plot.plot(x, y))
        print(self.curves[-1])
        self.show()

    @timeme
    def update_plot(self):
        self.curves[-1].setData(small_x, ys[self.current_y])
        self.current_y = (self.current_y + 1) % YS
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:38,代码来源:test_multiline.py

示例8: BusMonitorWidget

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
class BusMonitorWidget(QGroupBox):
    DEFAULT_PLOT_X_RANGE = 120
    BUS_LOAD_PLOT_MAX_SAMPLES = 5000

    def __init__(self, parent, node, iface_name):
        super(BusMonitorWidget, self).__init__(parent)
        self.setTitle('CAN bus activity (%s)' % iface_name.split(os.path.sep)[-1])

        self._node = node
        self._hook_handle = self._node.can_driver.add_io_hook(self._frame_hook)

        self._columns = [
            BasicTable.Column('Dir',
                              lambda e: (e[0].upper()),
                              searchable=False),
            BasicTable.Column('Local Time', TimestampRenderer(), searchable=False),
            BasicTable.Column('CAN ID',
                              lambda e: (('%0*X' % (8 if e[1].extended else 3, e[1].id)).rjust(8),
                                         colorize_can_id(e[1]))),
            BasicTable.Column('Data Hex',
                              lambda e: (' '.join(['%02X' % x for x in e[1].data]).ljust(3 * e[1].MAX_DATA_LENGTH),
                                         colorize_transfer_id(e))),
            BasicTable.Column('Data ASCII',
                              lambda e: (''.join([(chr(x) if 32 <= x <= 126 else '.') for x in e[1].data]),
                                         colorize_transfer_id(e))),
            BasicTable.Column('Src',
                              lambda e: render_node_id_with_color(e[1], 'src')),
            BasicTable.Column('Dst',
                              lambda e: render_node_id_with_color(e[1], 'dst')),
            BasicTable.Column('Data Type',
                              lambda e: render_data_type_with_color(e[1]),
                              resize_mode=QHeaderView.Stretch),
        ]

        self._log_widget = RealtimeLogWidget(self, columns=self._columns, font=get_monospace_font(),
                                             post_redraw_hook=self._redraw_hook)
        self._log_widget.on_selection_changed = self._update_measurement_display

        def flip_row_mark(row, col):
            if col == 0:
                item = self._log_widget.table.item(row, col)
                if item.icon().isNull():
                    item.setIcon(get_icon('circle'))
                    flash(self, 'Row %d was marked, click again to unmark', row, duration=3)
                else:
                    item.setIcon(QIcon())

        self._log_widget.table.cellPressed.connect(flip_row_mark)

        self._stat_update_timer = QTimer(self)
        self._stat_update_timer.setSingleShot(False)
        self._stat_update_timer.timeout.connect(self._update_stat)
        self._stat_update_timer.start(500)

        self._traffic_stat = TrafficStatCounter()

        self._stat_frames_tx = QLabel('N/A', self)
        self._stat_frames_rx = QLabel('N/A', self)
        self._stat_traffic = QLabel('N/A', self)

        self._load_plot = PlotWidget(background=(0, 0, 0))
        self._load_plot.setRange(xRange=(0, self.DEFAULT_PLOT_X_RANGE), padding=0)
        self._load_plot.setMaximumHeight(150)
        self._load_plot.setMinimumHeight(100)
        self._load_plot.setMinimumWidth(100)
        self._load_plot.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        self._load_plot.showGrid(x=True, y=True, alpha=0.4)
        self._load_plot.setToolTip('Frames per second')
        self._load_plot.getPlotItem().getViewBox().setMouseEnabled(x=True, y=False)
        self._load_plot.enableAutoRange()
        self._bus_load_plot = self._load_plot.plot(name='Frames per second', pen=mkPen(QColor(Qt.lightGray), width=1))
        self._bus_load_samples = [], []
        self._started_at_mono = time.monotonic()

        layout = QVBoxLayout(self)

        layout.addWidget(self._log_widget, 1)

        stat_vars_layout = QGridLayout(self)
        stat_layout_next_row = 0

        def add_stat_row(label, value):
            nonlocal stat_layout_next_row
            stat_vars_layout.addWidget(QLabel(label, self), stat_layout_next_row, 0)
            stat_vars_layout.addWidget(value, stat_layout_next_row, 1)
            value.setMinimumWidth(75)
            stat_layout_next_row += 1

        add_stat_row('Frames transmitted:', self._stat_frames_tx)
        add_stat_row('Frames received:', self._stat_frames_rx)
        add_stat_row('Frames per second:', self._stat_traffic)
        stat_vars_layout.setRowStretch(stat_layout_next_row, 1)

        stat_layout = QHBoxLayout(self)
        stat_layout.addLayout(stat_vars_layout)
        stat_layout.addWidget(self._load_plot, 1)

        layout.addLayout(stat_layout, 0)
        self.setLayout(layout)

#.........这里部分代码省略.........
开发者ID:hsteinhaus,项目名称:gui_tool,代码行数:103,代码来源:bus_monitor.py

示例9: PyQtGraphDataPlot

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
class PyQtGraphDataPlot(QWidget):

    limits_changed = Signal()

    def __init__(self, parent=None):
        super(PyQtGraphDataPlot, self).__init__(parent)
        self._plot_widget = PlotWidget()
        self._plot_widget.getPlotItem().addLegend()
        self._plot_widget.setBackground((255, 255, 255))
        self._plot_widget.setXRange(0, 10, padding=0)
        vbox = QVBoxLayout()
        vbox.addWidget(self._plot_widget)
        self.setLayout(vbox)
        self._plot_widget.getPlotItem().sigRangeChanged.connect(self.limits_changed)

        self._curves = {}
        self._current_vline = None

    def add_curve(self, curve_id, curve_name, curve_color=QColor(Qt.blue), markers_on=False):
        pen = mkPen(curve_color, width=1)
        symbol = "o"
        symbolPen = mkPen(QColor(Qt.black))
        symbolBrush = mkBrush(curve_color)
        # this adds the item to the plot and legend
        if markers_on:
            plot = self._plot_widget.plot(name=curve_name, pen=pen, symbol=symbol, symbolPen=symbolPen, symbolBrush=symbolBrush, symbolSize=4)
        else:
            plot = self._plot_widget.plot(name=curve_name, pen=pen)
        self._curves[curve_id] = plot

    def remove_curve(self, curve_id):
        curve_id = str(curve_id)
        if curve_id in self._curves:
            self._plot_widget.removeItem(self._curves[curve_id])
            del self._curves[curve_id]
            self._update_legend()
           
    def _update_legend(self):
        # clear and rebuild legend (there is no remove item method for the legend...)
        self._plot_widget.clear()
        self._plot_widget.getPlotItem().legend.items = []
        for curve in self._curves.values():
            self._plot_widget.addItem(curve)
        if self._current_vline:
            self._plot_widget.addItem(self._current_vline)
 
    def redraw(self):
        pass

    def set_values(self, curve_id, data_x, data_y):
        curve = self._curves[curve_id]
        curve.setData(data_x, data_y)

    def vline(self, x, color):
        if self._current_vline:
            self._plot_widget.removeItem(self._current_vline)
        self._current_vline = self._plot_widget.addLine(x=x, pen=color)

    def set_xlim(self, limits):
        # TODO: this doesn't seem to handle fast updates well
        self._plot_widget.setXRange(limits[0], limits[1], padding=0)

    def set_ylim(self, limits):
        self._plot_widget.setYRange(limits[0], limits[1], padding=0)

    def get_xlim(self):
        x_range, _ = self._plot_widget.viewRange()
        return x_range

    def get_ylim(self):
        _, y_range = self._plot_widget.viewRange()
        return y_range
开发者ID:Rescube,项目名称:rqt_common_plugins,代码行数:74,代码来源:pyqtgraph_data_plot.py

示例10: Aditi

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
class Aditi(QMainWindow):

    def __init__(self):
        QMainWindow.__init__(self)

        # title
        self.setWindowTitle("Aditi")
        self.setDockOptions(QMainWindow.VerticalTabs | QMainWindow.AnimatedDocks)
        #self.showMaximized()

        # model
        self.rawfiles_by_short_path = {}
        self.xic_by_rawfile_short_path = {}
        self.tic_by_rawfile_short_path = {}
        self.spec_by_rawfile_short_path = {}

        self.inf_line_tic_item = None
        self.curr_scan_id_by_short_path = {}

        # menu
        self.file_menu = self.menuBar().addMenu('&File')
        #self.file_menu.setTearOffEnabled(False)

        open_action = QAction("&Open...", self)
        open_action.setToolTip("Open a rawfile")
        open_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_O))
        self.file_menu.addAction(open_action)
        open_action.triggered.connect(self.show_open_dialog)

        exit_action = QAction("&Exit", self)
        exit_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q))
        self.file_menu.addAction(exit_action)
        exit_action.triggered.connect(self.quit)

        self.tab_widget = QTabWidget(self)
        # spectrum plot Widget
        self.graphics_layout_widget = GraphicsLayoutWidget(parent=self.tab_widget)

        self.graphics_layout_widget.keyPressEvent = self.handle_key_press_event

        self.graphics_layout_widget.useOpenGL(False)
        self.graphics_layout_widget.setAntialiasing(False)

        self.plot_widget_tic = self.graphics_layout_widget.addPlot(title="TIC(s)",
                                                                   labels={'left': "Intensity",
                                                                           'bottom': "Retention Time (sec)"})
        self.plot_widget_tic.showGrid(x=True, y=True)

        self.graphics_layout_widget.nextRow()

        self.plot_widget_spectrum = self.graphics_layout_widget.addPlot(title="Spectrum", labels={'left': "Intensity",
                                                                                                  'bottom': "m/z"})
        self.plot_widget_spectrum.showGrid(x=True, y=True)

        # finally add tab
        self.tab_widget.addTab(self.graphics_layout_widget, "Spectrum")

        # Xic plotWidget
        self.plot_widget_xic = PlotWidget(name="MainPlot", labels={'left': "Intensity",
                                                                   'bottom': "Retention Time (sec)"})
        self.plot_widget_xic.showGrid(x=True, y=True)

        self.tab_widget.addTab(self.plot_widget_xic, "Xic extraction")

        self.setCentralWidget(self.tab_widget)

        self.statusBar().showMessage("Ready")

        # dock 1
        self.rawfile_dock_widget = QDockWidget("Rawfiles")
        self.rawfile_table_view = QTableView()
        self.rawfile_table_view.horizontalHeader().setVisible(False)
        self.rawfile_table_view.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
        self.rawfile_dock_widget.setWidget(self.rawfile_table_view)

        self.rawfile_model = QStandardItemModel()
        self.rawfile_model.setHorizontalHeaderLabels(["Rawfiles"])
        self.rawfile_table_view.setModel(self.rawfile_model)

        self.rawfile_model.itemChanged.connect(self.item_changed)

        self.addDockWidget(0x2, self.rawfile_dock_widget)

        # xic dock widget extraction parameter
        self.xic_dock_widget = QDockWidget("Xic extraction")

        self.xic_widget = XicWidget()
        self.xic_widget.plotButton.clicked.connect(self.plot)

        self.xic_dock_widget.setWidget(self.xic_widget)
        self.addDockWidget(0x2, self.xic_dock_widget)

    def handle_key_press_event(self, evt):
        if self.inf_line_tic_item is None:
            return

        times = []
        if evt.key() == Qt.Key_Left:
            for rawfile in self.rawfiles_by_short_path.values()[:1]:
                if not rawfile.is_checked:
#.........这里部分代码省略.........
开发者ID:jerkos,项目名称:pymzdb,代码行数:103,代码来源:aditi.py

示例11: CamViewer

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]

#.........这里部分代码省略.........
        # Instantiate markers.
        self.marker_dict = {1:{}, 2:{}, 3:{}, 4:{}}
        marker_size = QPointF(20., 20.)
        self.marker_dict[1]['marker'] = ImageMarker((0, 0), size=marker_size, pen=mkPen((100, 100, 255), width=5))
        self.marker_dict[1]['button'] = self.ui.marker1Button
        self.marker_dict[1]['xlineedit'] = self.ui.marker1XPosLineEdit
        self.marker_dict[1]['ylineedit'] = self.ui.marker1YPosLineEdit

        self.marker_dict[2]['marker'] = ImageMarker((0, 0), size=marker_size, pen=mkPen((255, 100, 100), width=5))
        self.marker_dict[2]['button'] = self.ui.marker2Button
        self.marker_dict[2]['xlineedit'] = self.ui.marker2XPosLineEdit
        self.marker_dict[2]['ylineedit'] = self.ui.marker2YPosLineEdit

        self.marker_dict[3]['marker'] = ImageMarker((0, 0), size=marker_size, pen=mkPen((60, 255, 60), width=5))
        self.marker_dict[3]['button'] = self.ui.marker3Button
        self.marker_dict[3]['xlineedit'] = self.ui.marker3XPosLineEdit
        self.marker_dict[3]['ylineedit'] = self.ui.marker3YPosLineEdit

        self.marker_dict[4]['marker'] = ImageMarker((0, 0), size=marker_size, pen=mkPen((255, 60, 255), width=5))
        self.marker_dict[4]['button'] = self.ui.marker4Button
        self.marker_dict[4]['xlineedit'] = self.ui.marker4XPosLineEdit
        self.marker_dict[4]['ylineedit'] = self.ui.marker4YPosLineEdit
        # Disable auto-ranging the image (it feels strange when the zoom changes as you move markers around.)
        self.ui.imageView.getView().disableAutoRange()
        for d in self.marker_dict:
            marker = self.marker_dict[d]['marker']
            marker.setZValue(20)
            marker.hide()
            marker.sigRegionChanged.connect(self.markerMoved)
            self.ui.imageView.getView().addItem(marker)
            self.marker_dict[d]['button'].toggled.connect(self.enableMarker)
            curvepen = QPen(marker.pen)
            curvepen.setWidth(1)
            self.marker_dict[d]['xcurve'] = self.xLineoutPlot.plot(pen=curvepen)
            self.marker_dict[d]['ycurve'] = self.yLineoutPlot.plot(pen=curvepen)
            self.marker_dict[d]['xlineedit'].returnPressed.connect(self.markerPositionLineEditChanged)
            self.marker_dict[d]['ylineedit'].returnPressed.connect(self.markerPositionLineEditChanged)

        # Set up zoom buttons
        self.ui.zoomInButton.clicked.connect(self.zoomIn)
        self.ui.zoomOutButton.clicked.connect(self.zoomOut)
        self.ui.zoomToActualSizeButton.clicked.connect(self.zoomToActualSize)

        # Set up ROI buttons
        self.ui.setROIButton.clicked.connect(self.setROI)
        self.ui.resetROIButton.clicked.connect(self.resetROI)

        self.destroyed.connect(functools.partial(widget_destroyed, self.channels))


    @Slot()
    def zoomIn(self):
        self.ui.imageView.getView().scaleBy((0.5, 0.5))

    @Slot()
    def zoomOut(self):
        self.ui.imageView.getView().scaleBy((2.0, 2.0))

    @Slot()
    def zoomToActualSize(self):
        if len(self.image_data) == 0:
            return
        self.ui.imageView.getView().setRange(xRange=(0, self.image_data.shape[0]), yRange=(0, self.image_data.shape[1]), padding=0.0)

    def disable_all_markers(self):
        for d in self.marker_dict:
开发者ID:slaclab,项目名称:pydm,代码行数:70,代码来源:camviewer.py

示例12: __init__

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
    def __init__(self, time_series, topographies, filters, channel_names, fs, scores, scores_name='Mutual info', marks=None, *args):
        super(ScoredComponentsTable, self).__init__(*args)

        # attributes
        self.row_items_max_height = 125
        self.time_series = time_series
        self.marks = marks
        self.channel_names = channel_names
        self.fs = fs

        # set size and names
        self.columns = ['Selection', scores_name, 'Topography', 'Time series (push to switch mode)']
        self.setColumnCount(len(self.columns))
        self.setRowCount(time_series.shape[1])
        self.setHorizontalHeaderLabels(self.columns)

        # columns widgets
        self.checkboxes = []
        self.topographies_items = []
        self.plot_items = []
        self.scores = []
        _previous_plot_link = None
        for ind in range(self.rowCount()):

            # checkboxes
            checkbox = QtWidgets.QCheckBox()
            self.checkboxes.append(checkbox)
            self.setCellWidget(ind, self.columns.index('Selection'), checkbox)

            # topographies and filters
            topo_filter = TopoFilterCavas(self, self.channel_names, topographies[:, ind], filters[:, ind],
                                          self.row_items_max_height)
            self.topographies_items.append(topo_filter)
            self.setCellWidget(ind, self.columns.index('Topography'), topo_filter)

            # plots
            plot_widget = PlotWidget(enableMenu=False)
            if _previous_plot_link is not None:
                plot_widget.setXLink(_previous_plot_link)
                # plot_widget.setYLink(_previous_plot_link)
            _previous_plot_link = plot_widget
            plot_widget.plot(y=self.time_series[:, ind])
            if self.marks is not None:
                plot_widget.plot(y=self.marks*np.max(self.time_series[:, ind]), pen=(1,3))
                plot_widget.plot(y=-self.marks * np.max(self.time_series[:, ind]), pen=(1, 3))
            plot_widget.plot(x=np.arange(self.time_series.shape[0]) / fs)

            plot_widget.setMaximumHeight(self.row_items_max_height)
            plot_widget.plotItem.getViewBox().state['wheelScaleFactor'] = 0
            self.plot_items.append(plot_widget)
            self.setCellWidget(ind, 3, plot_widget)

            # scores
            score_widget = BarLabelWidget(scores[ind], max(scores), min(scores))
            self.scores.append(score_widget)
            self.setCellWidget(ind, self.columns.index(scores_name), score_widget)

        # formatting
        self.current_row = None
        self.horizontalHeader().setStretchLastSection(True)
        self.resizeColumnsToContents()
        self.resizeRowsToContents()

        # clickable 3 column header
        self.horizontalHeader().sectionClicked.connect(self.handle_header_click)
        self.is_spectrum_mode = False

        # reorder
        self.order = np.argsort(scores)
        self.reorder()

        # checkbox signals
        for checkbox in self.checkboxes:
            checkbox.stateChanged.connect(self.checkboxes_state_changed)

        # selection context menu
        header = self.horizontalHeader()
        header.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        header.customContextMenuRequested.connect(self.handle_header_menu)

        # ctrl+a short cut
        QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_A), self).activated.connect(self.ctrl_plus_a_event)

        # checkbox cell clicked
        self.cellClicked.connect(self.cell_was_clicked)
开发者ID:nikolaims,项目名称:nfb,代码行数:87,代码来源:scored_components_table.py

示例13: test

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
def test():
    ## BOILERPLATE ##
    import sys
    from PySide import QtGui, QtCore
    from math import sin
    if QtCore.QCoreApplication.instance() is None:
        app = QtGui.QApplication(sys.argv)
        import qt4reactor
        qt4reactor.install()
    ## BOILERPLATE ##

    #create the widget name even if you're not using it so that onStepped doesn't error
    listScanInputWidget = None  
    def log(x): print x
    
    
    
    #configure a layout for the plot widget & controls to go side by side on
    widget = QtGui.QWidget()
    widget.show()
    layout = QtGui.QHBoxLayout()
    widget.setLayout(layout)

    # create a plot and associated widget
    from pyqtgraph import PlotWidget
    plotWidget = PlotWidget()
    plot = plotWidget.plot()
    layout.addWidget(plotWidget)

    
    #configure a control panel layout
    controlPanel = QtGui.QWidget()
    cpLayout = QtGui.QVBoxLayout()
    controlPanel.setLayout(cpLayout)

    #create a scanToggleObject
    scanToggle = ScanToggleObject()
    
    '''
    #create a list scan input & widget
    listScanInput = ListScanInput(lambda(x):x,None)
    listScanInputWidget = ListScanInputWidget(listScanInput)
    cpLayout.addWidget(listScanInputWidget)
    scanToggle.toggled.connect(
        compose(
            listScanInputWidget.setDisabled,
            scanToggle.isToggled
        )
    )
    scanToggle.toggled.connect(partial(log,listScanInputWidget.listScanInput.positions))
    scanToggle.setInput(listScanInput.next)
    
    '''
    #create an interval scan input & widget
    intScanInput = IntervalScanInput(lambda(x):x,0,1000,10)
    scanToggle.setInput(intScanInput.next)
    intScanInputWidget = IntervalScanInputWidget(intScanInput,DEFAULTS)
    cpLayout.addWidget(intScanInputWidget)
    scanToggle.toggled.connect(
        compose(
            intScanInputWidget.setDisabled,
            scanToggle.isToggled
        )
    )

    
    #create scan output, for now a sine wave, this is where voltmeter would go
    def output(): 
        result = sin(float(output.i)/output.res)
        output.i+=1
        return result
    output.i = 0
    output.res = 10
    scanToggle.setOutput(output)
    
    
    # create a scan toggle
    x, y = [], []
    def onActivationRequested(x,y):
        while x: x.pop()
        while y: y.pop()
        scanToggle.toggle()
    
    # not performing any setup, so go ahead and connect activation requests to toggle
    scanToggle.activationRequested.connect(
        partial(
            onActivationRequested,
            x,
            y
        )
    )

    
    # create a toggle widget
    from qtutils.toggle import ToggleWidget
    cpLayout.addWidget(ToggleWidget(scanToggle))

    
    # handle the stepped signal
    from ab.abbase import sleep
#.........这里部分代码省略.........
开发者ID:creilly,项目名称:sitzlabexpcontrol,代码行数:103,代码来源:widget.py

示例14: SmartScanGUI

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
def SmartScanGUI():
    # oh god i'm so sorry. don't listen to him; he's never sorry.
    class self:
        x,y,err = [], [], []
        refData = {}

    #configure a layout for the plot widget & controls to go side by side on
    widget = QtGui.QWidget()
    container.append(widget)
    widget.show()
    layout = QtGui.QHBoxLayout()
    widget.setLayout(layout)
    
    # create a plot and associated widget
    plotWidget = PlotWidget()
    plot = plotWidget.plot()
    layout.addWidget(plotWidget,1)
    
    # configure a control panel layout
    cpLayout = QtGui.QVBoxLayout()
    layout.addLayout(cpLayout)

    # configure the output widget
    outputPane = ComboWidget()
    cpLayout.addWidget(LabelWidget('output',outputPane))


    ############################################################# VOLTMETER OUTPUT ###########################################################

    # add volt meter to scan output
    vmProtocol = yield getProtocol(
        (VM_DEBUG_SERVER_CONFIG if DEBUG else VM_SERVER_CONFIG)['url']
    )
    vmClient = VoltMeterClient(vmProtocol)    
    vmWidget = VoltMeterOutputWidget(vmClient)
    outputPane.addTab(vmWidget,'voltmeter')


    ############################################################# BEGIN INPUTS ###########################################################

    # configure the input widget
    inputPane = ComboWidget()
    inputPane.setTabPosition(inputPane.West)
    cpLayout.addWidget(LabelWidget('input',inputPane),1)    

    inputPane.addTab(
        ManualInputWidget(widget),
        'manual'
    )
    inputPane.addTab(
        ManualScanInputWidget(widget),
        'manual scan'
    )

    # algorithm for scan inputs is:
    # 0. check to see if input is disabled
    # 1. create client for server from protocol object
    # 2. create combo widget to hold interval and list widgets
    # 3. create interval widget using client object, add to combo
    # 4. same for list widget
    # 5. add combo widget to base combo widget (resulting in 2-D tab widget)

    
    ############################################################# STEPPER MOTOR INPUTS ###########################################################
    
    if INPUTS_TOGGLE[SM_BOOL]:
        # add stepper motors to scan input
        smProtocol = yield getProtocol(
            TEST_STEPPER_MOTOR_SERVER if DEBUG else STEPPER_MOTOR_SERVER 
        )    
        smClients = {
            smID:ChunkedStepperMotorClient(smProtocol,smID)
            for smID in (KDP,BBO,PDL,LID,POL)
        }

        for smID,smClient in smClients.items():
            thisInputWidget = CenterInputWidget(
                smClient.setPosition,
                smClient.cancel,
                -99999,
                99999,
                0,
                0,
                0,
                1000,
                0,
                10,
                smClient.getPosition                    
            )
        
            inputPane.addTab(
                thisInputWidget,
                {
                    KDP:'kdp',
                    BBO:'bbo',
                    PDL:'pdl',
                    LID:'lid',
                    POL:'pol'
                }[smID]
            )
#.........这里部分代码省略.........
开发者ID:creilly,项目名称:sitzlabexpcontrol,代码行数:103,代码来源:smartscan.py

示例15: SmartScanGUI

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import plot [as 别名]
def SmartScanGUI():
    # oh god i'm so sorry
    class self:
        x,y,err = [], [], []
        
    #configure a layout for the plot widget & controls to go side by side on
    widget = QtGui.QWidget()
    container.append(widget)
    widget.show()
    layout = QtGui.QHBoxLayout()
    widget.setLayout(layout)
    
    # create a plot and associated widget
    
    plotWidget = PlotWidget()
    plot = plotWidget.plot()
    layout.addWidget(plotWidget,1)
    
    # configure a control panel layout
    cpLayout = QtGui.QVBoxLayout()
    layout.addLayout(cpLayout)

    # configure the output widget
    outputWidget = ComboWidget()
    cpLayout.addWidget(LabelWidget('output',outputWidget))

    # add volt meter to scan output
    vmProtocol = yield getProtocol(
        (VM_DEBUG_SERVER_CONFIG if DEBUG else VM_SERVER_CONFIG)['url']
    )
    vmClient = VoltMeterClient(vmProtocol)    
    vmWidget = VoltMeterOutputWidget(vmClient)
    outputWidget.addTab(vmWidget,'voltmeter')

    # configure the input widget
    inputWidget = ComboWidget()
    inputWidget.setTabPosition(inputWidget.West)
    cpLayout.addWidget(LabelWidget('input',inputWidget),1)    

    inputWidget.addTab(
        ManualInputWidget(widget),
        'manual'
    )
    inputWidget.addTab(
        ManualScanInputWidget(widget),
        'manual scan'
    )

    # algorithm for scan inputs is:
    # 0. check to see if input is disabled
    # 1. create client for server from protocol object
    # 2. create combo widget to hold interval and list widgets
    # 3. create interval widget using client object, add to combo
    # 4. same for list widget
    # 5. add combo widget to base combo widget (resulting in 2-D tab widget)
    
    if INPUTS_TOGGLE[SM_BOOL]:
        # add stepper motors to scan input
        smProtocol = yield getProtocol(
            TEST_STEPPER_MOTOR_SERVER if DEBUG else STEPPER_MOTOR_SERVER 
        )    
        smClients = {
            smID:ChunkedStepperMotorClient(smProtocol,smID)
            for smID in (KDP,BBO,PDL)
        }

        for smID,smClient in smClients.items():
            combo_input_widget = ComboWidget()
            
            combo_input_widget.addTab(
                CenterInputWidget(
                    smClient.setPosition,
                    smClient.cancel,
                    -99999,
                    99999,
                    0,
                    0,
                    0,
                    1000,
                    0,
                    10,
                    smClient.getPosition                    
                ),
                'interval'
            )
        
            combo_input_widget.addTab(
                ListInputWidget(
                    smClient.setPosition,
                    smClient.cancel
                ),
                'list'
            )
        
            inputWidget.addTab(
                combo_input_widget,
                {
                    KDP:'kdp',
                    BBO:'bbo',
                    PDL:'pdl'
#.........这里部分代码省略.........
开发者ID:gositz,项目名称:sitzlabexpcontrol,代码行数:103,代码来源:smartscan.py


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