• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyqtgraph.mkPen函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_update_coordinates

    def test_update_coordinates(self):
        graph = self.graph
        xy = self.xy = (np.array([1, 2]), np.array([3, 4]))
        graph.reset_graph()

        scatterplot_item = graph.scatterplot_item
        scatterplot_item_sel = graph.scatterplot_item_sel
        data = scatterplot_item.data

        np.testing.assert_almost_equal(scatterplot_item.getData(), xy)
        np.testing.assert_almost_equal(scatterplot_item_sel.getData(), xy)
        scatterplot_item.setSize([5, 6])
        scatterplot_item.setSymbol([7, 8])
        scatterplot_item.setPen([mkPen(9), mkPen(10)])
        scatterplot_item.setBrush([11, 12])
        data["data"] = np.array([13, 14])

        xy[0][0] = 0
        graph.update_coordinates()
        np.testing.assert_almost_equal(graph.scatterplot_item.getData(), xy)
        np.testing.assert_almost_equal(graph.scatterplot_item_sel.getData(), xy)

        # Graph updates coordinates instead of creating new items
        self.assertIs(scatterplot_item, graph.scatterplot_item)
        self.assertIs(scatterplot_item_sel, graph.scatterplot_item_sel)
        np.testing.assert_almost_equal(data["size"], [5, 6])
        np.testing.assert_almost_equal(data["symbol"], [7, 8])
        self.assertEqual(data["pen"][0], mkPen(9))
        self.assertEqual(data["pen"][1], mkPen(10))
        np.testing.assert_almost_equal(data["brush"], [11, 12])
        np.testing.assert_almost_equal(data["data"], [13, 14])
开发者ID:mstrazar,项目名称:orange3,代码行数:31,代码来源:test_owscatterplotbase.py


示例2: generatePicture

 def generatePicture(self):
     self.picture = pg.QtGui.QPicture()
     if self.pen is None or self.pos is None or self.adjacency is None:
         return
     
     p = pg.QtGui.QPainter(self.picture)
     try:
         pts = self.pos[self.adjacency]
         pen = self.pen
         if isinstance(pen, np.ndarray):
             lastPen = None
             for i in range(pts.shape[0]):
                 pen = self.pen[i]
                 if np.any(pen != lastPen):
                     lastPen = pen
                     if pen.dtype.fields is None:
                         p.setPen(pg.mkPen(color=(pen[0], pen[1], pen[2], pen[3]), width=1))                            
                     else:
                         p.setPen(pg.mkPen(color=(pen['red'], pen['green'], pen['blue'], pen['alpha']), width=pen['width']))
                 p.drawLine(pg.QtCore.QPointF(*pts[i][0]), pg.QtCore.QPointF(*pts[i][1]))
         else:
             if pen == 'default':
                 pen = pg.getConfigOption('foreground')
             p.setPen(pg.mkPen(pen))
             pts = pts.reshape((pts.shape[0]*pts.shape[1], pts.shape[2]))
             path = fn.arrayToQPath(x=pts[:,0], y=pts[:,1], connect='pairs')
             p.drawPath(path)
     finally:
         p.end()
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:29,代码来源:GraphItem.py


示例3: plotAnalyzer

    def plotAnalyzer(self):
        """Visualize the points found by the auto analyzer
        
        Returns:
            None: Description
        """
        if hasattr(self, 'an'):
            s1 = self.an.analysedSignals[0]
            s2 = self.an.analysedSignals[1]

            # signal 1
            # ROI
            self.anROI1 = self.pw2.plot(np.linspace(s1.ROIleft-100, s1.ROIleft)/1000,
                                       np.ones(50)*s1.avg,
                                       pen=pg.mkPen('w',width=2))
            # points
            self.anPlot1 = self.pw2.plot([s1.peak.idx/1000],
                                         [s1.peak.h], symbolBrush=('w'), symbolSize=5)
            self.anPlot1 = self.pw2.plot([s1.hwLeft.idx/1000],
                                         [s1.hwLeft.h], symbolBrush=('w'), symbolSize=5)
            self.anPlot1 = self.pw2.plot([s1.hwRight.idx/1000],
                                         [s1.hwRight.h], symbolBrush=('w'), symbolSize=5)

            # signal 2
            # ROI
            self.anROI2 = self.pw2.plot(np.linspace(s2.ROIleft-100, s2.ROIleft)/1000,
                                       np.ones(50)*s2.avg,
                                       pen=pg.mkPen('r',width=2))
            # points
            self.anPlot2 = self.pw2.plot([s2.peak.idx/1000],
                                         [s2.peak.h], symbolBrush=('r'), symbolSize=5)
            self.anPlot2 = self.pw2.plot([s2.hwLeft.idx/1000],
                                         [s2.hwLeft.h], symbolBrush=('r'), symbolSize=5)
            self.anPlot2 = self.pw2.plot([s2.hwRight.idx/1000],
                                         [s2.hwRight.h], symbolBrush=('r'), symbolSize=5)
开发者ID:HanzoYu,项目名称:GSoundAnalyzer,代码行数:35,代码来源:GSoundAnalyzer_fixedRange.py


示例4: __init__

 def __init__(self, angle, col, dangle=5, parent=None):
     super().__init__(parent)
     color = QColor(0, 0, 0) if col else QColor(128, 128, 128)
     angle_d = np.rad2deg(angle)
     angle_2 = 90 - angle_d - dangle
     angle_1 = 270 - angle_d + dangle
     dangle = np.deg2rad(dangle)
     arrow1 = pg.ArrowItem(
         parent=self, angle=angle_1, brush=color, pen=pg.mkPen(color)
     )
     arrow1.setPos(np.cos(angle - dangle), np.sin(angle - dangle))
     arrow2 = pg.ArrowItem(
         parent=self, angle=angle_2, brush=color, pen=pg.mkPen(color)
     )
     arrow2.setPos(np.cos(angle + dangle), np.sin(angle + dangle))
     arc_x = np.fromfunction(
         lambda i: np.cos((angle - dangle) + (2 * dangle) * i / 120.),
         (121,), dtype=int
     )
     arc_y = np.fromfunction(
         lambda i: np.sin((angle - dangle) + (2 * dangle) * i / 120.),
         (121,), dtype=int
     )
     pg.PlotCurveItem(
         parent=self, x=arc_x, y=arc_y, pen=pg.mkPen(color), antialias=False
     )
开发者ID:PrimozGodec,项目名称:orange3,代码行数:26,代码来源:owradviz.py


示例5: insertPlot

	def insertPlot(self, xAry      = None,        yAry      = None,        plotArea  = None, legend    = None,
						 plotName  = None,        lineColor = (0,0,0,255), lineWidth = 1,    lineStyle = QtCore.Qt.SolidLine, 
						 dotColor  = (0,0,0,255), dotSize   = 5,           dotSym    = 0,    addLegend = True ):
		Sym = [ 'o', 's', 't', 'd', '+' ]
		if plotName == None:
			plotName = 'Untitle {0}'.format(self.plotIDCounter)
			
		if ( xAry != None and yAry != None):
			line = plotArea.plot( np.array(xAry), np.array(yAry), name = plotName,
							  pen=pg.mkPen(color = lineColor, width=lineWidth, style=lineStyle), symbol = Sym[dotSym] ) 

		else:
			plotAry = xAry if xAry != None else yAry
			xAry = np.linspace( 0, len( plotAry )-1, len( plotAry ))
			yAry = np.array( plotAry )
			line = plotArea.plot( np.array(xAry), np.array(yAry), name = plotName,
							  pen=pg.mkPen(color = lineColor, width = lineWidth, style = lineStyle), symbol = Sym[dotSym] ) 

		self.addLineHolder(line)

		self.reWrapp_line(line)

		line.line_val(   name   = plotName,       color   = lineColor,
						 width  = lineWidth,      style   = lineStyle, 
						 symbol = Sym[dotSym],    visible = True,      viewNum = plotArea.viewBoxNum)		

		line.symbol_val( color   = dotColor,      size    = dotSize,
						 penC    = (0,255,0,255), penW    = 2,
						 outLine = False,         visible = True )
		print line.line_color()
		plotArea.showGrid(x=True, y=True)
		if addLegend:
			legend.addItem( line, plotName )
		return line
开发者ID:s910324,项目名称:Sloth,代码行数:34,代码来源:plotSubWin.py


示例6: __init__

    def __init__(self, clock):
        pg.ItemGroup.__init__(self)
        self.size = clock.size
        self.item = QtGui.QGraphicsEllipseItem(QtCore.QRectF(0, 0, self.size, self.size))
        self.item.translate(-self.size*0.5, -self.size*0.5)
        self.item.setPen(pg.mkPen(100,100,100))
        self.item.setBrush(clock.brush)
        self.hand = QtGui.QGraphicsLineItem(0, 0, 0, self.size*0.5)
        self.hand.setPen(pg.mkPen('w'))
        self.hand.setZValue(10)
        self.flare = QtGui.QGraphicsPolygonItem(QtGui.QPolygonF([
            QtCore.QPointF(0, -self.size*0.25),
            QtCore.QPointF(0, self.size*0.25),
            QtCore.QPointF(self.size*1.5, 0),
            QtCore.QPointF(0, -self.size*0.25),
            ]))
        self.flare.setPen(pg.mkPen('y'))
        self.flare.setBrush(pg.mkBrush(255,150,0))
        self.flare.setZValue(-10)
        self.addItem(self.hand)
        self.addItem(self.item)
        self.addItem(self.flare)
 
        self.clock = clock
        self.i = 1
        
        self._spaceline = None
开发者ID:acrsilva,项目名称:animated-zZz-machine,代码行数:27,代码来源:relativity.py


示例7: _setup_plot

    def _setup_plot(self):
        self.plot.clear()
        explained_ratio = self._variance_ratio
        explained = self._cumulative
        p = min(len(self._variance_ratio), self.maxp)

        self.plot.plot(numpy.arange(p), explained_ratio[:p],
                       pen=pg.mkPen(QColor(Qt.red), width=2),
                       antialias=True,
                       name="Variance")
        self.plot.plot(numpy.arange(p), explained[:p],
                       pen=pg.mkPen(QColor(Qt.darkYellow), width=2),
                       antialias=True,
                       name="Cumulative Variance")

        self._line = pg.InfiniteLine(
            angle=90, pos=self._nselected_components() - 1, movable=True,
            bounds=(0, p - 1)
        )
        self._line.setCursor(Qt.SizeHorCursor)
        self._line.setPen(pg.mkPen(QColor(Qt.darkGray), width=5))
        self._line.sigPositionChanged.connect(self._on_cut_changed)

        self.plot.addItem(self._line)
        self.plot.setRange(xRange=(0.0, p - 1), yRange=(0.0, 1.0))
        self._update_axis()
开发者ID:MPOWER4RU,项目名称:orange3,代码行数:26,代码来源:owpca.py


示例8: update_display_settings

 def update_display_settings(self):
     """ sets the colors for the ROIs and whether or not to show the label """
     # handle the labels
     if self.Main.Options.ROI['show_labels'] == True:
         [ROI.labelItem.show() for ROI in self.ROI_list]
     if self.Main.Options.ROI['show_labels'] == False:
         [ROI.labelItem.hide() for ROI in self.ROI_list]
         
     # handle the ROI colors
     nActiveROIs = len(self.Main.Options.ROI['active_ROIs'])
     
     # one ROI active, active/inactive color scheme
     if nActiveROIs <= 1:
         for ROI in self.ROI_list:
             if ROI.active == True:
                 pen = pg.mkPen(self.Main.Options.ROI['active_color'],width=1.8)
             if ROI.active == False:
                 pen = pg.mkPen(self.Main.Options.ROI['inactive_color'],width=1.8)
             ROI.set_Pen(pen)
                         
     # multiple ROI active, traces colored to ROI
     if nActiveROIs > 1:
         colors = self.Main.Processing.calc_colors(nActiveROIs)
         for i,ROI_id in enumerate(self.Main.Options.ROI['active_ROIs']):
             ROI = self.ROI_list[ROI_id]
             pen = pg.mkPen(colors[i],width=1.8)
             ROI.set_Pen(pen)
     pass
开发者ID:Dahaniel,项目名称:ILTIS,代码行数:28,代码来源:ROIs_Object.py


示例9: __init__

    def __init__(self,Main=None,label=None,ViewBox=None):
#        super(myROI,self).__init__()
        self.Main = Main
        self.label = label
        self.ViewBox = self.parentItem()
        self.children = [] # a list of GraphicsItems
        
        self.active = False
        self.center = self.get_center()
        self.labelItem = pg.TextItem(text=label,anchor=(0.5,0.5))
        self.update_center()

        self.ViewBox.addItem(self.labelItem)
        self.children.append(self.labelItem)
    
        # link signals
        self.sigRemoveRequested.connect(self.Main.ROIs.remove_ROI_request)
        self.proxy = pg.SignalProxy(self.sigRegionChanged, rateLimit=30, slot=self.Main.ROIs.ROI_region_changed) # rate limit movement
        self.setAcceptedMouseButtons(QtCore.Qt.LeftButton)
        self.sigClicked.connect(self.Main.ROIs.ROI_clicked_handler)
#        self.sigHoverEvent.connect(self.Main.ROIs.ROI_hover_handler)
        
        # pens
        self.active_pen = pg.mkPen(self.Main.Options.ROI['active_color'],width=1.8)
        self.inactive_pen = pg.mkPen(self.Main.Options.ROI['inactive_color'],width=1.8)
        self.hover_pen = pg.mkPen(255,255,0,width=1)
开发者ID:Dahaniel,项目名称:ILTIS,代码行数:26,代码来源:ROIs_Object.py


示例10: test_init_spots

def test_init_spots():
    spots = [
        {'x': 0, 'y': 1},
        {'pos': (1, 2), 'pen': None, 'brush': None, 'data': 'zzz'},
    ]
    s = pg.ScatterPlotItem(spots=spots)
    
    # Check we can display without errors
    plot.addItem(s)
    app.processEvents()
    plot.clear()
    
    # check data is correct
    spots = s.points()
    
    defPen = pg.mkPen(pg.getConfigOption('foreground'))

    assert spots[0].pos().x() == 0
    assert spots[0].pos().y() == 1
    assert spots[0].pen() == defPen
    assert spots[0].data() is None
    
    assert spots[1].pos().x() == 1
    assert spots[1].pos().y() == 2
    assert spots[1].pen() == pg.mkPen(None)
    assert spots[1].brush() == pg.mkBrush(None)
    assert spots[1].data() == 'zzz'
开发者ID:AeroEng43,项目名称:pyqtgraph,代码行数:27,代码来源:test_ScatterPlotItem.py


示例11: setupUi

    def setupUi(self):
        self.resize(1200, 900)
        gr = pg.PlotWidget(parent=self, background=[255, 255, 255])
        dtait = pg.PlotDataItem(pen=pg.mkPen('r', width=4))
        dtait2 = pg.PlotDataItem(pen=pg.mkPen('b', width=4))
        dtait.setVisible(True)
        gr.plotItem.addItem(dtait)
        gr.plotItem.addItem(dtait2)
        pl = gr.getPlotItem()
        vl = QVBoxLayout(self)
        vl.addWidget(gr)
        self.graph = gr
        self._plot_rms = dtait
        self._plot_ave = dtait2

        hl = QHBoxLayout()
        vl.addItem(hl)

        self.dirs = sorted([f for f in os.listdir() if os.path.isdir(f)])
        self.cb_dirs = QComboBox(self)
        self.cb_dirs.addItems(self.dirs)
        self.cb_dirs.currentTextChanged.connect(self._changedir)
        hl.addWidget(self.cb_dirs)

        self.cb_planes = QComboBox(self)
        self.cb_planes.addItems(self.planes + ('Wlkick', ))
        self.cb_planes.currentTextChanged.connect(self._changePlane)
        hl.addWidget(self.cb_planes)
开发者ID:lnls-fac,项目名称:collective_effects,代码行数:28,代码来源:analyse_results.py


示例12: insertPlot

	def insertPlot(self, xAry = None, yAry = None, plotArea = None, legend = None, plotName = None, 
				lineColor = (0,0,0,255), lineWidth = 1, lineStyle = QtCore.Qt.SolidLine, 
				dotColor  = (0,0,0,255), dotSize   = 4,  dotSym = 0    ):
			Sym = [ 'o', 's', 't', 'd', '+' ]
			if plotName == None:
				plotName = 'Untitle {0}'.format(self.plotCounter)
				self.plotCounter += 1
			if ( xAry != None and yAry != None):
				line = plotArea.plot( np.array(xAry), np.array(yAry), name = plotName,
								  pen=pg.mkPen(color = lineColor, width=lineWidth, style=lineStyle), symbol = Sym[dotSym] ) 
				self.plotLineHolder.append(line)
			else:
				plotAry = xAry if xAry != None else yAry
				xAry = np.linspace( 0, len( plotAry )-1, len( plotAry ))
				yAry = np.array( plotAry )
				line = plotArea.plot( np.array(xAry), np.array(yAry), name = plotName,
								  pen=pg.mkPen(color = lineColor, width=lineWidth, style=lineStyle), symbol = Sym[dotSym] ) 
				self.plotLineHolder.append(line)
			line.setSymbolBrush( pg.mkBrush(  color = dotColor ))
			line.setSymbolPen(   None )
			line.setSymbolSize( dotSize )
			plotArea.showGrid(x=True, y=True)
#            line.setPen(pg.mkPen(color = (255,0,0,255), width=5, style=QtCore.Qt.SolidLine))
#            self.w.setLabel('left', "Y Axis", units='A')
#            self.w.setLabel('bottom', "Y Axis", units='s')
#            self.w.setLogMode(x=True, y=False)
			legend.addItem( line, plotName )        
开发者ID:s910324,项目名称:Sloth,代码行数:27,代码来源:plotSubWin+(ori).py


示例13: commit

    def commit(self):
        new_stack = None

        self.Error.nan_in_image.clear()
        self.Error.invalid_axis.clear()

        self.plotview.plotItem.clear()

        if self.data and len(self.data.domain.attributes) and self.attr_x and self.attr_y:
            try:
                shifts, new_stack = process_stack(self.data, self.attr_x, self.attr_y,
                                                  upsample_factor=100, use_sobel=self.sobel_filter,
                                                  ref_frame_num=self.ref_frame_num-1)
            except NanInsideHypercube as e:
                self.Error.nan_in_image(e.args[0])
            except InvalidAxisException as e:
                self.Error.invalid_axis(e.args[0])
            else:
                # TODO: label axes
                frames = np.linspace(1, shifts.shape[0], shifts.shape[0])
                self.plotview.plotItem.plot(frames, shifts[:, 0],
                                            pen=pg.mkPen(color=(255, 40, 0), width=3),
                                            symbol='o', symbolBrush=(255, 40, 0), symbolPen='w',
                                            symbolSize=7)
                self.plotview.plotItem.plot(frames, shifts[:, 1],
                                            pen=pg.mkPen(color=(0, 139, 139), width=3),
                                            symbol='o', symbolBrush=(0, 139, 139), symbolPen='w',
                                            symbolSize=7)
                self.plotview.getPlotItem().setLabel('bottom', 'Frame number')
                self.plotview.getPlotItem().setLabel('left', 'Shift / pixel')
                self.plotview.getPlotItem().addLine(self.ref_frame_num,
                                                    pen=pg.mkPen(color=(150, 150, 150), width=3,
                                                                 style=Qt.DashDotDotLine))

        self.Outputs.newstack.send(new_stack)
开发者ID:markotoplak,项目名称:orange-infrared,代码行数:35,代码来源:owstackalign.py


示例14: _setup_plot

    def _setup_plot(self):
        explained_ratio = self._variance_ratio
        explained = self._cumulative
        (p, ) = explained.shape

        self.plot.plot(numpy.arange(p), explained_ratio,
                       pen=pg.mkPen(QColor(Qt.red), width=2),
                       antialias=True,
                       name="Variance")
        self.plot.plot(numpy.arange(p), explained,
                       pen=pg.mkPen(QColor(Qt.darkYellow), width=2),
                       antialias=True,
                       name="Cumulative Variance")

        self._line = pg.InfiniteLine(
            angle=90, pos=self._nselected_components() - 1, movable=True,
            bounds=(0, p - 1)
        )
        self._line.setCursor(Qt.SizeHorCursor)
        self._line.setPen(pg.mkPen(QColor(Qt.darkGray), width=1.5))
        self._line.sigPositionChanged.connect(self._on_cut_changed)

        self.plot.addItem(self._line)
        self.plot.setRange(xRange=(0.0, p - 1), yRange=(0.0, 1.0))
        axis = self.plot.getAxis("bottom")
        axis.setTicks([[(i, "C{}".format(i + 1)) for i in range(p)]])
开发者ID:VesnaT,项目名称:orange3,代码行数:26,代码来源:owpca.py


示例15: plot_data

    def plot_data(self, data):
        self.clear()
        self.showButtons()
        self.data = data
        try:
            points = data.shape[0]
            lines = data.shape[1]
            if lines > 1:
                # self.getViewBox().disableAutoRange()

                # Color option for separate multiple plots
                # for i in range(lines):
                #     item = PathItem(np.arange(points), data[:,i].flatten())
                #     item.setPen(pg.mkPen((i, lines)))
                #     self.widget.addItem(item)

                xdata = np.tile(np.arange(points), (lines, 1))

                # Assume data is vertical
                item = MultiLine(xdata, data.T)
                item.setPen(pg.mkPen('w'))
                self.addItem(item)

                # self.getViewBox().enableAutoRange()
                self.autoRange()
        except IndexError:
            self.plot(np.arange(len(data)) / self.x_scale, data / self.y_scale, pen=pg.mkPen(width=1))

            # Update title
            text = 'Recording length: %f (s)' % (len(data) / self.x_scale)
            self.s.title_updated.emit(text)
开发者ID:eagonmeng,项目名称:Bamboo,代码行数:31,代码来源:default_plot_widget.py


示例16: edit

    def edit(self, index, trigger, event):
        if trigger == QAbstractItemView.DoubleClicked:
            print("DoubleClick Killed!")

            model = self.model()
            _filename = model.filePath(index)

            pen1 = pg.mkPen(color=(self.pColor - 1, 32), width=2)
            pen2 = pg.mkPen(color=(self.pColor - 1, 32), width=1, style=QtCore.Qt.DashLine)

            data_snr = perf_reader.perf_snr_reader(_filename)
            data_ber = perf_reader.perf_ber_reader(_filename)
            data_fer = perf_reader.perf_fer_reader(_filename)

            self.class_var.clearPlots()
            self.class_var.clear()

            self.class_var.plot(x=data_snr, y=data_ber, pen=pen1, symbol="x", name="BER plot")
            self.class_var.plot(x=data_snr, y=data_fer, pen=pen2, symbol="x", name="FER plot")

            self.pColor = self.pColor + 1

            return False

        return QTreeView.edit(self, index, trigger, event)
开发者ID:bonben,项目名称:Plotter4FECs,代码行数:25,代码来源:r_viewer.py


示例17: plot

    def plot(self, Rs=None, Vg=0):
        pg.setConfigOption('background', 'w')
        pg.setConfigOption('foreground', 'k')

        # Generate plot
        plt = pg.plot(title=self.__class__.__name__, clear=True)
        plt.setYRange(0, self.IDSS_MAX)
        plt.setXRange(self.VP_MAX, 0)
        plt.showGrid(True, True, 1.0)
        plt.setLabel('left', "Id (mA)")
        plt.setLabel('bottom', "Vgs (V)")

        (x, y) = self.id_max_points()
        plt.plot(x, y, pen=pg.mkPen('g', width=3))

        (x, y) = self.id_min_points()
        plt.plot(x, y, pen=pg.mkPen('b', width=3))

        if Rs is not None:
            (x, y) = self.vg_intercept(Rs, Vg)
            plt.plot(x, y, pen=pg.mkPen('r', width=3))

        # Display plot
        QtGui.QApplication.instance().exec_()
        pg.exit()
开发者ID:devttys0,项目名称:EE,代码行数:25,代码来源:jfet.py


示例18: __init__

    def __init__(self, viewBox, side, pxs=512):

        self.showed = False
        self.vb = viewBox
        self.side = side              # side is 128 or 82, the grid size
        self.pxs = pxs

        pen = pg.mkPen(color=(255, 255, 0), width=1,
                       style=QtCore.Qt.SolidLine, antialias=True)
        pen2 = pg.mkPen(color=(255, 255, 0), width=0.75,
                        style=QtCore.Qt.DotLine, antialias=True)

        self.rectT = QtGui.QGraphicsRectItem()
        self.rectT.setPen(pen)
        self.rectR = QtGui.QGraphicsRectItem()
        self.rectR.setPen(pen)
        self.sqrT = QtGui.QGraphicsRectItem()
        self.sqrT.setPen(pen2)
        self.sqrR = QtGui.QGraphicsRectItem()
        self.sqrR.setPen(pen2)
        self.yLine = pg.InfiniteLine(pen=pen2)
        self.xLine = pg.InfiniteLine(pen=pen2, angle=0)
        self.xLineR = pg.InfiniteLine(pen=pen2, angle=0)

        self.setDimensions()
开发者ID:fedebarabas,项目名称:tormenta,代码行数:25,代码来源:viewbox_tools.py


示例19: draw_spectrum_analyzer

	def draw_spectrum_analyzer(all_frames, thresh_frames):
		time.sleep(1) # Wait just one second
		pw = pg.plot(title="Spectrum Analyzer") # Window title
		pg.setConfigOptions(antialias=True) # Enable antialias for better resolution
		pw.win.resize(800, 300) # Define window size
		pw.win.move(540 * SCREEN_WIDTH / 1920, 500 * SCREEN_HEIGHT / 1080) # Define window position
		while True: # Loop over the frames of the audio / data chunks
			data = ''.join(all_frames[-1:]) # Get only the last frame of all frames
			data = numpy.fromstring(data, 'int16') # Binary string to numpy int16 data format
			pw.setMouseEnabled(y=False) # Disable mouse
			pw.setYRange(0,1000) # Set Y range of graph
			pw.setXRange(-(RATE/16), (RATE/16), padding=0) # Set X range of graph relative to Bit Rate
			pwAxis = pw.getAxis("bottom") # Get bottom axis
			pwAxis.setLabel("Frequency [Hz]") # Set bottom axis label
			f, Pxx = HearingPerception.find_frequency(data) # Call find frequency function
			f = f.tolist() # Numpy array to list
			Pxx = (numpy.absolute(Pxx)).tolist() # Numpy array to list
			try: # Try this block
				if thresh_frames[-1:][0] == EMPTY_CHUNK: # If last thresh frame is equal to EMPTY CHUNK
					pw.plot(x=f,y=Pxx, clear=True, pen=pg.mkPen('w', width=1.0, style=QtCore.Qt.SolidLine)) # Then plot with white pen
				else: # If last thresh frame is not equal to EMPTY CHUNK
					pw.plot(x=f,y=Pxx, clear=True, pen=pg.mkPen('y', width=1.0, style=QtCore.Qt.SolidLine)) # Then plot with yellow pen
			except IndexError: # If we are getting an IndexError because of this -> thresh_frames[-1:][0]
				pw.plot(x=f,y=Pxx, clear=True, pen=pg.mkPen('w', width=1.0, style=QtCore.Qt.SolidLine)) # Then plot with white pen
			pg.QtGui.QApplication.processEvents() # ???
			time.sleep(0.05) # Wait a few miliseconds
开发者ID:Unmukt,项目名称:Cerebrum,代码行数:26,代码来源:perception.py


示例20: test_init_spots

def test_init_spots():
    plot = pg.PlotWidget()
    # set view range equal to its bounding rect. 
    # This causes plots to look the same regardless of pxMode.
    plot.setRange(rect=plot.boundingRect())
    spots = [
        {'x': 0, 'y': 1},
        {'pos': (1, 2), 'pen': None, 'brush': None, 'data': 'zzz'},
    ]
    s = pg.ScatterPlotItem(spots=spots)
    
    # Check we can display without errors
    plot.addItem(s)
    app.processEvents()
    plot.clear()
    
    # check data is correct
    spots = s.points()
    
    defPen = pg.mkPen(pg.getConfigOption('foreground'))

    assert spots[0].pos().x() == 0
    assert spots[0].pos().y() == 1
    assert spots[0].pen() == defPen
    assert spots[0].data() is None
    
    assert spots[1].pos().x() == 1
    assert spots[1].pos().y() == 2
    assert spots[1].pen() == pg.mkPen(None)
    assert spots[1].brush() == pg.mkBrush(None)
    assert spots[1].data() == 'zzz'
开发者ID:andrewpaulreeves,项目名称:soapy,代码行数:31,代码来源:test_ScatterPlotItem.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyqtgraph.mkQApp函数代码示例发布时间:2022-05-27
下一篇:
Python pyqtgraph.mkColor函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap