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


Python pyqtgraph.mkPen方法代码示例

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


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

示例1: generatePicture

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def generatePicture(self):
            ## pre-computing a QPicture object allows paint() to run much more quickly,
            ## rather than re-drawing the shapes every time.
            self.picture = QtGui.QPicture()
            p = QtGui.QPainter(self.picture)
            p.setPen(pg.mkPen(color='w', width=0.4))  # 0.4 means w*2
            a = pg.AxisItem('bottom', pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True)
            a.setFixedWidth(1)
            a.setWidth(1)
            a.setLabel(show=True)
            a.setGrid(grid=True)
            labelStyle = {'color': '#FFF', 'font-size': '14pt'}
            a.setLabel('label text', units='V', **labelStyle)
            # w = (self.data[1][0] - self.data[0][0]) / 3.
            w = 0.2
            for (t, open, close, min, max) in self.data:
                p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
                if open > close:
                    p.setBrush(pg.mkBrush('g'))
                else:
                    p.setBrush(pg.mkBrush('r'))
                p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
                pg.setConfigOption('leftButtonPan', False)
            p.end() 
开发者ID:sunshinelover,项目名称:chanlun,代码行数:26,代码来源:uiChanlunWidget.py

示例2: update

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def update(self):
        if not self.ear.data is None and not self.ear.fft is None:
            pcmMax=np.max(np.abs(self.ear.data))
            if pcmMax>self.maxPCM:
                self.maxPCM=pcmMax
                self.grPCM.plotItem.setRange(yRange=[-pcmMax,pcmMax])
            if np.max(self.ear.fft)>self.maxFFT:
                self.maxFFT=np.max(np.abs(self.ear.fft))
                #self.grFFT.plotItem.setRange(yRange=[0,self.maxFFT])
                self.grFFT.plotItem.setRange(yRange=[0,1])
            self.pbLevel.setValue(1000*pcmMax/self.maxPCM)
            pen=pyqtgraph.mkPen(color='b')
            self.grPCM.plot(self.ear.datax,self.ear.data,pen=pen,clear=True)
            pen=pyqtgraph.mkPen(color='r')
            self.grFFT.plot(self.ear.fftx,self.ear.fft/self.maxFFT,pen=pen,clear=True)
        QtCore.QTimer.singleShot(1, self.update) # QUICKLY repeat 
开发者ID:swharden,项目名称:Python-GUI-examples,代码行数:18,代码来源:go.py

示例3: plot

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def plot():
    start = pg.ptime.time()
    n = 15
    pts = 100
    x = np.linspace(0, 0.8, pts)
    y = np.random.random(size=pts)*0.8
    for i in range(n):
        for j in range(n):
            ## calling PlotWidget.plot() generates a PlotDataItem, which 
            ## has a bit more overhead than PlotCurveItem, which is all 
            ## we need here. This overhead adds up quickly and makes a big
            ## difference in speed.
            
            #plt.plot(x=x+i, y=y+j)
            plt.addItem(pg.PlotCurveItem(x=x+i, y=y+j))
            
            #path = pg.arrayToQPath(x+i, y+j)
            #item = QtGui.QGraphicsPathItem(path)
            #item.setPen(pg.mkPen('w'))
            #plt.addItem(item)
            
    dt = pg.ptime.time() - start
    print("Create plots took: %0.3fms" % (dt*1000))

## Plot and clear 5 times, printing the time it took 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:27,代码来源:multiplePlotSpeedTest.py

示例4: fastPlot

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def fastPlot():
    ## Different approach:  generate a single item with all data points.
    ## This runs about 20x faster.
    start = pg.ptime.time()
    n = 15
    pts = 100
    x = np.linspace(0, 0.8, pts)
    y = np.random.random(size=pts)*0.8
    xdata = np.empty((n, n, pts))
    xdata[:] = x.reshape(1,1,pts) + np.arange(n).reshape(n,1,1)
    ydata = np.empty((n, n, pts))
    ydata[:] = y.reshape(1,1,pts) + np.arange(n).reshape(1,n,1)
    conn = np.ones((n*n,pts))
    conn[:,-1] = False # make sure plots are disconnected
    path = pg.arrayToQPath(xdata.flatten(), ydata.flatten(), conn.flatten())
    item = QtGui.QGraphicsPathItem(path)
    item.setPen(pg.mkPen('w'))
    plt.addItem(item)
    
    dt = pg.ptime.time() - start
    print("Create plots took: %0.3fms" % (dt*1000))


## Plot and clear 5 times, printing the time it took 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:26,代码来源:multiplePlotSpeedTest.py

示例5: addPlot

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def addPlot(self, plot):
        image = plot.image
        if not self.plots:
            self.setImageItem(image)

        self.plots.append(plot)
        self.setSymColormap()

        # hist_pen = pg.mkPen((170, 57, 57, 255), width=1.)
        image.setLookupTable(self.getLookupTable)

        def updateLevels():
            image.setLevels(self.region.getRegion())

        self.sigLevelChangeFinished.connect(updateLevels)
        self.sigLevelsChanged.connect(updateLevels)
        updateLevels() 
开发者ID:pyrocko,项目名称:kite,代码行数:19,代码来源:multiplot.py

示例6: refresh

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def refresh(self):
        self.plot.clear()
        
        n = 0
        for k in self.controller.positive_cluster_labels:
            if not self.controller.cluster_visible[k]:
                continue
            
            if k not in self.all_isi:
                self._compute_isi(k)
            
            isi = self.all_isi[k]
            if len(isi) ==0:
                return
            
            bins = np.arange(self.params['bin_min'], self.params['bin_max'], self.params['bin_size'])
            count, bins = np.histogram(isi, bins=bins)
            
            qcolor = self.controller.qcolors[k]
            curve = pg.PlotCurveItem(bins[:-1], count, pen=pg.mkPen(qcolor, width=3))
            self.plot.addItem(curve) 
开发者ID:tridesclous,项目名称:tridesclous,代码行数:23,代码来源:isiviewer.py

示例7: __init__

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def __init__(self, plot, pen=None):
        """ Initiates the crosshars onto a plot given the pen style.

        Example pen:
        pen=pg.mkPen(color='#AAAAAA', style=QtCore.Qt.DashLine)
        """
        super().__init__()

        self.vertical = pg.InfiniteLine(angle=90, movable=False, pen=pen)
        self.horizontal = pg.InfiniteLine(angle=0, movable=False, pen=pen)
        plot.addItem(self.vertical, ignoreBounds=True)
        plot.addItem(self.horizontal, ignoreBounds=True)

        self.position = None
        self.proxy = pg.SignalProxy(plot.scene().sigMouseMoved, rateLimit=60,
                                    slot=self.mouseMoved)
        self.plot = plot 
开发者ID:ralph-group,项目名称:pymeasure,代码行数:19,代码来源:curves.py

示例8: update_plot

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def update_plot(self, filename):
        self.plot.clear()
        if not os.path.isdir(filename) and filename != '':
            try:
                results = Results.load(str(filename))
            except ValueError:
                return
            except Exception as e:
                raise e

            curve = ResultsCurve(results,
                                 x=self.plot_widget.plot_frame.x_axis,
                                 y=self.plot_widget.plot_frame.y_axis,
                                 pen=pg.mkPen(color=(255, 0, 0), width=1.75),
                                 antialias=True
                                 )
            curve.update()

            self.plot.addItem(curve)

            self.preview_param.clear()
            for key, param in results.procedure.parameter_objects().items():
                new_item = QtGui.QTreeWidgetItem([param.name, str(param)])
                self.preview_param.addTopLevelItem(new_item)
            self.preview_param.sortItems(0, QtCore.Qt.AscendingOrder) 
开发者ID:ralph-group,项目名称:pymeasure,代码行数:27,代码来源:widgets.py

示例9: callback_graph_clicked

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def callback_graph_clicked(self, event):
        """ set the curve highlighted to be normal """
        print('graph clicked')
        if self.curve_clicked:
            if event.modifiers() == QtCore.Qt.ControlModifier:
                pass
            else:
                for curve in self.curve_highlighted[:-1]:
                    curve.setShadowPen(pg.mkPen((200, 200, 200),  width=1,  cosmetic=True))
                self.curve_highlighted = self.curve_highlighted[-1:]
                
        if len(self.curve_highlighted) > 0 and not self.curve_clicked:
            for curve in self.curve_highlighted:
                curve.setShadowPen(pg.mkPen((120, 120, 120),  width=1,  cosmetic=True))
                self.curve_highlighted = []
                self.plotting_data_tableView.setCurrentCell(0,  0)
                
        self.curve_clicked = False 
开发者ID:Marxlp,项目名称:pyFlightAnalysis,代码行数:20,代码来源:analysis.py

示例10: triggerKnobEnabledChange

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def triggerKnobEnabledChange(self, state):
        self.triggerKnobSource.setEnabled(state)
        self.triggerKnobDirection.setEnabled(state)
        if state:
            if self.triggX is None:
                self.triggX = 0.5
            if self.triggY is None:
                self.triggY = 0
            if self.triggerDiamond is None:
                self.triggerDiamond = pg.RectROI([self.triggX * self.samples / self.ratioBin, self.triggY],
                                                 [0, 0], invertible=True, pen=pg.mkPen(None))
                self.triggerDiamond.sigRegionChanged.connect(self.triggerDiamondUpdate)
                self.viewPlot.addItem(self.triggerDiamond)
        else:
            self.viewPlot.removeItem(self.triggerDiamond)
            self.triggerDiamond = None
        self.triggerReset = True 
开发者ID:picotech,项目名称:picosdk-python-examples,代码行数:19,代码来源:picopyscope.py

示例11: generatePicture

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def generatePicture(self):
            ## pre-computing a QPicture object allows paint() to run much more quickly,
            ## rather than re-drawing the shapes every time.
            self.picture = QtGui.QPicture()
            p = QtGui.QPainter(self.picture)
            p.setPen(pg.mkPen(color='w', width=0.4))  # 0.4 means w*2
            # w = (self.data[1][0] - self.data[0][0]) / 3.
            w = 0.2
            for (t, open, close, min, max) in self.data:
                p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
                if open > close:
                    p.setBrush(pg.mkBrush('g'))
                else:
                    p.setBrush(pg.mkBrush('r'))
                p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
            p.end() 
开发者ID:sunshinelover,项目名称:chanlun,代码行数:18,代码来源:demoUi.py

示例12: generatePicture

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def generatePicture(self):
            ## pre-computing a QPicture object allows paint() to run much more quickly,
            ## rather than re-drawing the shapes every time.
            self.picture = QtGui.QPicture()
            p = QtGui.QPainter(self.picture)
            p.setPen(pg.mkPen(color='r', width=0.4))  # 0.4 means w*2
            # w = (self.data[1][0] - self.data[0][0]) / 3.
            w = 0.2
            for (t, open, close, min, max) in self.data:
                p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
                if open > close:
                    p.setBrush(pg.mkBrush('g'))
                else:
                    p.setBrush(pg.mkBrush('r'))
                p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
            p.end() 
开发者ID:zhengwsh,项目名称:InplusTrader_Linux,代码行数:18,代码来源:uiBasicWidget.py

示例13: cell_chosen

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def cell_chosen(self):
        if self.Floaded:
            self.cell_mask()
            self.ROIedit.setText(str(self.ichosen))
            rgb = np.array(self.colors[self.ichosen])
            self.cellscatter.setData(self.xext, self.yext,
                                     pen=pg.mkPen(list(rgb)),
                                     brush=pg.mkBrush(list(rgb)), size=3)
            self.cellscatter_side.setData(self.xext, self.yext,
                                     pen=pg.mkPen(list(rgb)),
                                     brush=pg.mkBrush(list(rgb)), size=3)

            if self.ichosen >= len(self.stat):
                self.ichosen = len(self.stat) - 1
            self.cell_mask()
            self.ft = self.Fcell[self.ichosen,:]
            self.plot_trace()
            self.p2.setXLink('plot_shift')
            self.jump_to_frame()
            self.show() 
开发者ID:MouseLand,项目名称:suite2p,代码行数:22,代码来源:reggui.py

示例14: __init__

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def __init__(self, manager: BarManager):
        """"""
        super().__init__()

        self._manager: BarManager = manager

        self._bar_picutures: Dict[int, QtGui.QPicture] = {}
        self._item_picuture: QtGui.QPicture = None

        self._up_pen: QtGui.QPen = pg.mkPen(
            color=UP_COLOR, width=PEN_WIDTH
        )
        self._up_brush: QtGui.QBrush = pg.mkBrush(color=UP_COLOR)

        self._down_pen: QtGui.QPen = pg.mkPen(
            color=DOWN_COLOR, width=PEN_WIDTH
        )
        self._down_brush: QtGui.QBrush = pg.mkBrush(color=DOWN_COLOR)

        self._rect_area: Tuple[float, float] = None

        # Very important! Only redraw the visible part and improve speed a lot.
        self.setFlag(self.ItemUsesExtendedStyleOption) 
开发者ID:nicai0609,项目名称:Python-CTPAPI,代码行数:25,代码来源:candle_demo.py

示例15: _init_line

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import mkPen [as 别名]
def _init_line(self) -> None:
        """
        Create line objects.
        """
        self._v_lines: Dict[str, pg.InfiniteLine] = {}
        self._h_lines: Dict[str, pg.InfiniteLine] = {}
        self._views: Dict[str, pg.ViewBox] = {}

        pen = pg.mkPen(WHITE_COLOR)

        for plot_name, plot in self._plots.items():
            v_line = pg.InfiniteLine(angle=90, movable=False, pen=pen)
            h_line = pg.InfiniteLine(angle=0, movable=False, pen=pen)
            view = plot.getViewBox()

            for line in [v_line, h_line]:
                line.setZValue(0)
                line.hide()
                view.addItem(line)

            self._v_lines[plot_name] = v_line
            self._h_lines[plot_name] = h_line
            self._views[plot_name] = view 
开发者ID:nicai0609,项目名称:Python-CTPAPI,代码行数:25,代码来源:candle_demo.py


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