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


Python pyqtgraph.mkPen函数代码示例

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


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


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