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


Python PlotWidget.show方法代码示例

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


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

示例1: CamViewer

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

#.........这里部分代码省略.........
    @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:
            self.marker_dict[d]['button'].setChecked(False)
            self.marker_dict[d]['marker'].setPos((0, 0))

    @Slot(bool)
    def enableMarker(self, checked):
        any_markers_visible = False
        for d in self.marker_dict:
            marker = self.marker_dict[d]['marker']
            button = self.marker_dict[d]['button']
            any_markers_visible = any_markers_visible or button.isChecked()
            marker.setVisible(button.isChecked())
            self.markerMoved(d)
            self.marker_dict[d]['xcurve'].setVisible(button.isChecked())
            self.marker_dict[d]['ycurve'].setVisible(button.isChecked())
            self.marker_dict[d]['xlineedit'].setEnabled(button.isChecked())
            self.marker_dict[d]['ylineedit'].setEnabled(button.isChecked())
        if any_markers_visible:
            self.xLineoutPlot.show()
            self.yLineoutPlot.show()
        else:
            self.xLineoutPlot.hide()
            self.yLineoutPlot.hide()

    @Slot()
    def markerPositionLineEditChanged(self):
        for d in self.marker_dict:
            marker = self.marker_dict[d]['marker']
            x_line_edit = self.marker_dict[d]['xlineedit']
            y_line_edit = self.marker_dict[d]['ylineedit']
            try:
                new_x = int(x_line_edit.text())
                new_y = int(y_line_edit.text())
                if new_x <= marker.maxBounds.width() and new_y <= marker.maxBounds.height():
                    marker.setPos((new_x, new_y))
            except:
                pass
            coords = marker.getPixelCoords()
            x_line_edit.setText(str(coords[0]))
            y_line_edit.setText(str(coords[1]))

    @Slot(object)
    def markerMoved(self, marker):
        self.updateLineouts()
        for marker_index in self.marker_dict:
            marker = self.marker_dict[marker_index]['marker']
            x_line_edit = self.marker_dict[marker_index]['xlineedit']
            y_line_edit = self.marker_dict[marker_index]['ylineedit']
            coords = marker.getPixelCoords()
            x_line_edit.setText(str(coords[0]))
            y_line_edit.setText(str(coords[1]))
开发者ID:slaclab,项目名称:pydm,代码行数:70,代码来源:camviewer.py

示例2: __init__

# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import show [as 别名]
class Plotter:
    """ This class communicates with the matplotlib library
    and plot the data

    """

    def __init__(self, size):
        """Initialize the plot window, size defines the shape and size
        of the figure
        0 - None, 
        1 - 8x6, 
        11 (default) - 12x8,
        2 - 2 figs 8x8,
        12 - 2 figs 12x8

        """
#        print('ok')
        class CustomViewBox(pg.ViewBox):
           def __init__(self, *args, **kwds):
               pg.ViewBox.__init__(self, *args, **kwds)
               self.setMouseMode(self.RectMode)
        
            ## reimplement right-click to zoom out
           def mouseClickEvent(self, ev):
               if ev.button() == QtCore.Qt.RightButton and QtGui.QApplication.keyboardModifiers()==QtCore.Qt.ControlModifier:
                   self.autoRange()
               else:
                   pg.ViewBox.mouseClickEvent(self, ev)
            
           def mouseDragEvent(self, ev):
               mod = QtGui.QApplication.keyboardModifiers()
               if mod == QtCore.Qt.ControlModifier:
                   self.setMouseMode(self.PanMode)
               else:
                   self.setMouseMode(self.RectMode)
               
               if ev.button() == QtCore.Qt.RightButton:
                   pg.ViewBox.mouseDragEvent(self, ev)
               else:
                   pg.ViewBox.mouseDragEvent(self, ev)

        self.vb = CustomViewBox()
# not necessary?    def clear(self):

    def ylog(self):
        """
           Change y-scale to log
        """
        vr = self._widget.plotItem.viewRange()
        xr = vr[0]
        yr = vr[1]
#        print(xr,yr)
        if yr[0]<=0:
            yr[0]=1
        yr[0]=np.log10(yr[0])
        yr[1]=np.log10(yr[1])
#        print(xr,yr)
        self._widget.plotItem.disableAutoRange()
        self._widget.plotItem.setLogMode(x=False, y=True)
        self._widget.plotItem.setRange(xRange=xr, yRange=yr,padding=None)

    def ylin(self):
        """
           Change y-scale to linear
        """
        vr = self._widget.plotItem.viewRange()
        xr = vr[0]
        yr = vr[1]
#        print(xr,yr)
        yr[0]=10**yr[0]
        yr[1]=10**yr[1]
#        print(xr,yr)
        self._widget.plotItem.disableAutoRange()
        self._widget.plotItem.setLogMode(x=False, y=False)
        self._widget.plotItem.setRange(xRange=xr, yRange=yr,padding=None)

    def plot1d(self, plot, xlim=None, ylim=None):
        """ Plot 1D histogram
            The mode defines the way the data are presented,
            'histogram' is displayed with steps
            'function' with continuus line
            'errorbar' with yerrorbars

            The norm (normalization factor) and bin_size are given
            for the display purposes only. The histogram is not altered.

        """

        histo = plot.histogram

        self._widget = PlotWidget(viewBox=self.vb)
        plt = self._widget.plotItem
        plt.setTitle(histo.title)
        plt.plot(histo.x_axis, histo.weights)
        self._widget.show()
#        if plot.mode == 'histogram':
#            current_plot.plot()
#        win.show()
#        app.processEvents()

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


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