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


Python pyqtgraph.mkBrush函数代码示例

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


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

示例1: __init__

 def __init__(self,name=None,items=None,colors=None):
     super(CParameterTree,self).__init__()
     self.name = name
     self.setColumnCount(4)
     self.setHeaderHidden(True)
     self.setDragEnabled(False)
     self.header = pg.TreeWidgetItem([name])
     self.setIndentation(0)
     headerBackgroundColor = pg.mkBrush(color=(100,100,100))
     fontcolor = pg.mkBrush(color=(255,255,255))
     self.setupHeader()
     # self.header.setBackground(0,headerBackgroundColor)
     # self.header.setBackground(1,headerBackgroundColor)
     # self.header.setBackground(2,headerBackgroundColor)
     # self.header.setBackground(3,headerBackgroundColor)
     # self.header.setForeground(0,fontcolor)
     # self.addTopLevelItem(self.header)
     # self.header.setSizeHint(0,QtCore.QSize(-1, 25))
     # self.setColumnWidth (0, 100)
     # self.setColumnWidth (1, 50)
     # self.setColumnWidth (2, 70)
     self.setColumnWidth (3, 5)
     if items is not None: self.names = items
     else: self.names = []
     self.items = {} # main widgets
     self.colors = {} # color widgets
     self.boxes = {} # checkbox widgets
     self.groups = {} # just empty items
     if items: self.addItems(items,colors)
开发者ID:ishovkun,项目名称:TCI,代码行数:29,代码来源:CParameterTree.py

示例2: __init__

    def __init__(self, pen=None, brush=None, **opts):
        """
        Arguments for each surface are:
           x1,x2 - position of center of _physical surface_
           r1,r2 - radius of curvature
           d1,d2 - diameter of optic
        """
        defaults = dict(x1=-2, r1=100, d1=25.4, x2=2, r2=100, d2=25.4)
        defaults.update(opts)
        ParamObj.__init__(self)
        self.surfaces = [CircleSurface(defaults['r1'], defaults['d1']), CircleSurface(-defaults['r2'], defaults['d2'])]
        pg.GraphicsObject.__init__(self)
        for s in self.surfaces:
            s.setParentItem(self)
        
        if pen is None:
            self.pen = pg.mkPen((220,220,255,200), width=1, cosmetic=True)
        else:
            self.pen = pg.mkPen(pen)
        
        if brush is None: 
            self.brush = pg.mkBrush((230, 230, 255, 30))
        else:
            self.brush = pg.mkBrush(brush)

        self.setParams(**defaults)
开发者ID:acrsilva,项目名称:animated-zZz-machine,代码行数:26,代码来源:pyoptic.py

示例3: setPlot

    def setPlot(self, plot):
        """setting the ScatterPlotWidget for the node"""
        self.plot = plot

        # ScatterPlotItem for the current position of the 'Pointer'
        self.spiPos = pg.ScatterPlotItem(size=3,
                                         pen=pg.mkPen(None),
                                         brush=pg.mkBrush(255, 255, 255, 255))

        # ScatterPlotItem for the path, while drawing
        self.spiPath = pg.ScatterPlotItem(size=3,
                                          pen=pg.mkPen(None),
                                          brush=pg.mkBrush(255, 0, 0, 255))

        # ScatterPlotItem for the recognized template
        self.spiTemplate = pg.ScatterPlotItem(size=3,
                                              pen=pg.mkPen(None),
                                              brush=pg.mkBrush(0,
                                                               100, 255, 255))

        # setting the x and y range to width and height of the ir camera field
        self.plot.setXRange(0, 1024)
        self.plot.setYRange(0, 768)

        # appending legend to display which color shows which data
        self.legend = pg.LegendItem(offset=(-1, 1))
        self.legend.addItem(self.spiPos, 'position')
        self.legend.addItem(self.spiPath, 'path')
        self.legend.addItem(self.spiTemplate, 'template')
        self.legend.setParentItem(self.plot)
开发者ID:freakimkaefig,项目名称:itt_lamm_lechler,代码行数:30,代码来源:gestures.py

示例4: add_measure_rois

    def add_measure_rois(self):
        # First, remove existing rois
        for roi in self._rois:
            self._plot_item.removeItem(roi)

        if len(self._measure_rois) == 0:
            for i in range(3):
                view_range = self._plot_item.viewRange()
                x_vrange = view_range[0][1] - view_range[0][0]
                x_len = x_vrange * 0.25
                x_pos = view_range[0][0] + x_vrange * 0.1 + x_len * 1.1 * i

                roi = LinearRegionItem(values=[x_pos, x_pos + x_len],
                                       brush=pg.mkBrush(
                                           QColor(152, 251, 152, 50)),
                                       removable=False)

                if i == 1:
                    roi.setBrush(pg.mkBrush(QColor(255, 69, 0, 50)))

                self._measure_rois.append(roi)

            for roi in self._measure_rois:
                roi.sigRemoveRequested.connect(
                    lambda: Dispatch.on_updated_roi.emit(
                        measure_rois=self._measure_rois))
                roi.sigRegionChangeFinished.connect(
                    lambda: Dispatch.on_updated_roi.emit(
                        measure_rois=self._measure_rois))

            # Connect events
            Dispatch.on_updated_roi.emit(measure_rois=self._measure_rois)

        for roi in self._measure_rois:
            self._plot_item.addItem(roi)
开发者ID:astrofrog,项目名称:specviz,代码行数:35,代码来源:sub_windows.py

示例5: updateSelectedPenPointsGraphics

    def updateSelectedPenPointsGraphics(self, selectedpendata=None):
        if selectedpendata is None:
            selectedpendata = MarkWriteMainWindow.instance().project.selectedpendata

        pen=pen2=None
        brush=brush2=None
        psize=SETTINGS['spatialplot_selectedpoint_size']

        if MarkWriteMainWindow.instance().project.isSelectedDataValidForNewSegment():
            pen = pg.mkPen(SETTINGS['spatialplot_selectedvalid_color'],
                           width=SETTINGS['spatialplot_selectedpoint_size'])
            pen2 = pg.mkPen(SETTINGS['spatialplot_selectedvalid_color'].darker(300),
                           width=SETTINGS['spatialplot_selectedpoint_size'])
            brush = pg.mkBrush(SETTINGS['spatialplot_selectedvalid_color'])
            brush2 = pg.mkBrush(SETTINGS['spatialplot_selectedvalid_color'].darker(300))
        else:
            pen = pg.mkPen(SETTINGS['spatialplot_selectedinvalid_color'],
                           width=SETTINGS['spatialplot_selectedpoint_size'])
            brush = pg.mkBrush(SETTINGS['spatialplot_selectedinvalid_color'])
            pen2 = pg.mkPen(SETTINGS['spatialplot_selectedinvalid_color'].darker(300),
                           width=SETTINGS['spatialplot_selectedpoint_size'])
            brush2 = pg.mkBrush(SETTINGS['spatialplot_selectedinvalid_color'].darker(300))

        penarray = np.empty(selectedpendata.shape[0], dtype=object)
        penarray[:] = pen
        penarray[selectedpendata['pressure'] == 0] = pen2
        brusharray = np.empty(selectedpendata.shape[0], dtype=object)
        brusharray[:] = brush
        brusharray[selectedpendata['pressure'] == 0] = brush2

        self.selectedPlotDataItem.setData(x=selectedpendata[X_FIELD],
                                          y=selectedpendata[Y_FIELD], pen=None,
                                          symbol='o', symbolSize=psize,
                                          symbolBrush=brusharray, symbolPen=penarray)
开发者ID:isolver,项目名称:OpenHandWrite,代码行数:34,代码来源:spatialview.py

示例6: generatePicture

    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('w'))
        barWidth = (self.data[1][0] - self.data[0][0]) / 3.
        
        for index,item in enumerate(self.data):
            time = item[0]
            open = item[1]
            high = item[2]
            low = item[3]
            close = item[4]
            
            # 01.draw high-low line,when high == low,it means the symbol is not traded.
            if(high != low):
                p.drawLine(QtCore.QPointF(index, low), QtCore.QPointF(index, high))
            
            # 02.decide the color of candle
            if open > close:
                p.setBrush(pg.mkBrush('g'))
            else:
                p.setBrush(pg.mkBrush('r'))
            
            # 03.draw the candle rect
            x=index-barWidth
            y=open
            width= barWidth*2
            height=close-open

            p.drawRect(QtCore.QRectF(x,y ,width,height))
        p.end()
开发者ID:UpSea,项目名称:ZipLineMid,代码行数:33,代码来源:PyQtGraphCandles02.py

示例7: __init__

    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        
        pg.setConfigOption('background', 'w')
        pg.setConfigOption('foreground', 'k')
        pg.setConfigOptions(antialias=False)
        self.scopeWidget = pg.PlotWidget()
        self.scopeWidget.setTitle('Scope trace', size='12')

        self.vbl = QtGui.QVBoxLayout()
        self.vbl.addWidget(self.scopeWidget)
        self.setLayout(self.vbl)
        self.scopeWidget.setLabel('left', 'Signal', units='V')
        self.scopeWidget.setLabel('bottom', 'Time', units='s')
        self.scopeWidget.showGrid(x=False, y=True)
        self.scopeWidget.clear()

        self.lr1 = pg.LinearRegionItem([0,0], brush=pg.mkBrush(0,0,160,80))
        self.lr2 = pg.LinearRegionItem([0,0], brush=pg.mkBrush(52,124,23,80))
        self.lr1.setZValue(10)
        self.lr2.setZValue(10)
        self.scopeWidget.addItem(self.lr2)
        self.scopeWidget.addItem(self.lr1)
        self.lr1.setMovable(False)
        self.lr2.setMovable(False)
开发者ID:mikekohlhoff,项目名称:ryexpctl,代码行数:25,代码来源:PyQtGraphWidgetScope.py

示例8: plotMA

    def plotMA(self, G, R, z_scores, z_cuttof):
        ratio, intensity = expression.ratio_intensity(G, R)

        validmask = (numpy.isfinite(ratio) &
                     numpy.isfinite(intensity) &
                     numpy.isfinite(z_scores))
        for array in [ratio, intensity, z_scores]:
            if numpy.ma.is_masked(array):
                validmask &= ~array.mask

        filtered_ind = numpy.ma.where(validmask)
        ratio = numpy.take(ratio, filtered_ind)
        intensity = numpy.take(intensity, filtered_ind)
        z_scores = numpy.take(z_scores, filtered_ind)

        red_ind = numpy.ma.where(numpy.ma.abs(z_scores) >= z_cuttof)
        blue_ind = numpy.ma.where(numpy.ma.abs(z_scores) < z_cuttof)

        red_xdata, red_ydata = intensity[red_ind], ratio[red_ind]
        blue_xdata, blue_ydata = intensity[blue_ind], ratio[blue_ind]

        self.graph.clear()
        line = pg.InfiniteLine(pos=(0, 0), angle=0, pen=pg.mkPen((0, 0, 0)))
        self.graph.addItem(line)

        red_points = ScatterPlotItem(
            x=red_xdata, y=red_ydata,
            brush=pg.mkBrush((255, 0, 0, 100)), size=6, antialias=True)
        blue_points = ScatterPlotItem(
            x=blue_xdata, y=blue_ydata,
            brush=pg.mkBrush((0, 0, 255, 100)), size=6, antialias=True)

        self.graph.addItem(red_points)
        self.graph.addItem(blue_points)
开发者ID:nagyistoce,项目名称:orange-bio,代码行数:34,代码来源:OWMAPlot.py

示例9: makeGraph

 def makeGraph(self):
     #g1 = pg.GraphItem(pos=self.pos, adj=self.links[self.rope], pen=0.2, symbol=None)
     brushes = np.where(self.fixed, pg.mkBrush(0,0,0,255), pg.mkBrush(50,50,200,255))
     g2 = pg.GraphItem(pos=self.pos, adj=self.links[self.push & self.pull], pen=0.5, brush=brushes, symbol='o', size=(self.mass**0.33), pxMode=False)
     p = pg.ItemGroup()
     #p.addItem(g1)
     p.addItem(g2)
     return p
开发者ID:grg2rsr,项目名称:ILTIS,代码行数:8,代码来源:chain.py

示例10: generatePicture

 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('w'))
     halfBarWidth = (self.data[1][0] - self.data[0][0]) / 3.
     
     for index,item in enumerate(self.data):
         time = item[0]
         open = item[1]
         high = item[2]
         low = item[3]
         close = item[4]
         
         if(True):
             x = time
         else:
             x = index
         # 01.draw high-low line,when high == low,it means the symbol is not traded.
         if(high != low):
             p.drawLine(QtCore.QPointF(x, low), QtCore.QPointF(x, high))
         
         # 02.decide the color of candle
         if open > close:
             p.setBrush(pg.mkBrush('g'))
         else:
             p.setBrush(pg.mkBrush('r'))
         
         # 03.draw the candle rect
         x=x-halfBarWidth
         y=open
         barWidth= halfBarWidth*2
         height=close-open
         rectToDraw = QtCore.QRectF(x,y ,barWidth,height)
         
         if(not self.bSelected):
             for lastRect in self.lastClicked:
                 for newRect in self.ptsClicked:
                     if(lastRect == newRect):
                         self.bSelected = True
         
         
         
         if(not self.bSelected):
             for rect in self.ptsClicked:
                 if(rect == rectToDraw):
                     self.lastClicked = self.ptsClicked 
                     p.setPen(pg.mkPen('w'))
                     p.setBrush(pg.mkBrush('w')) 
         else:
             self.bSelected = False
             
         p.drawRect(QtCore.QRectF(x,y ,barWidth,height))
         self.dataRects[index]=QtCore.QRectF(x,y ,barWidth,height)
     p.end()
开发者ID:UpSea,项目名称:midProjects,代码行数:56,代码来源:pgCandleItem.py

示例11: setupGUI

	def setupGUI(self):
		self.setWindowTitle("Edit effectibve stress formula")
		self.setGeometry(500, 300, 350, 200)
		# self.centralWidget = QtGui.QWidget()
		# self.setCentralWidget(self.centralWidget)
		self.centralLayout = QtGui.QVBoxLayout()
		# self.centralWidget.setLayout(self.centralLayout)
		self.setLayout(self.centralLayout)
		self.variablesText = QtGui.QLabel('')

		tree = pg.TreeWidget()
		tree.setHeaderHidden(True)
		tree.setIndentation(0)
		tree.setColumnCount(3)
		
		# stuff to make gray background for tree widget
		g = pg.mkBrush(240,240,240)
		b = pg.mkBrush(0,0,0)
		w = pg.mkBrush(255,255,255)
		bgBrush = pg.mkBrush(255,0,0)
		tree.setFrameShape(QtGui.QFrame.NoFrame)
		palette = QtGui.QPalette(g, g, g, g, g, b, b, g, g)
		# tree.setPalette(palette)

		axStressItem = pg.TreeWidgetItem(['Axial stress'])
		# axStressItem.setTextAlignment(0,0)
		# axStressItem.setBackground(1,w)
		confStressItem = pg.TreeWidgetItem(['Confining pressure'])
		# confStressItem.setTextAlignment(0,0)
		porePressItem = pg.TreeWidgetItem(['Pore pressure'])
		biotItem = pg.TreeWidgetItem(['Biot coefficient'])
		porePressItem.setTextAlignment(0,0)

		self.axStressBox = QtGui.QLineEdit()
		self.confStressBox = QtGui.QLineEdit()
		self.porePressBox = QtGui.QLineEdit()
		self.biotBox = pg.SpinBox(value=1, bounds=[0.5, 1],step=0.1)
		
		axStressItem.setWidget(1,self.axStressBox)
		confStressItem.setWidget(1,self.confStressBox)
		biotItem.setWidget(1,self.biotBox)

		porePressItem.setWidget(1,self.porePressBox)
		tree.addTopLevelItem(axStressItem)
		tree.addTopLevelItem(confStressItem)
		tree.addTopLevelItem(porePressItem)
		tree.addTopLevelItem(biotItem)

		self.centralLayout.addWidget(self.variablesText)
		self.centralLayout.addWidget(tree)
		# self.centralLayout.addWidget(self.buttonsWidget)

		tree.setColumnWidth(0,120)
		tree.setColumnWidth(1,170)
		tree.setColumnWidth(2,10)
开发者ID:ishovkun,项目名称:GeoTravis,代码行数:55,代码来源:EffectiveStressSettingsWidget.py

示例12: change_to_image

    def change_to_image(self, image):
        """ Set curTrace to TRACE. Update all the buttons/table_slice
        and then highlight the proper row in the table_traces."""
        # Deselecting the previous curTrace
        if self.curImage is not None:
            index = -1
            for row in range(self.table_images.rowCount()):
                item = self.table_images.item(row, 0)
                if str(item.text()) == self.curImage.name:
                    index = row
            if index != -1: 
                item = self.table_images.item(index, 0)
                item.setBackground(pqg.mkBrush((255, 255, 255, 255)))

        # Selecting the current trace
        index = -1
        for row in range(self.table_images.rowCount()):
            item = self.table_images.item(row, 0)
            if str(item.text()) == image.name:
                index = row
        if index != -1:
            item = self.table_images.item(index, 0)
            item.setBackground(pqg.mkBrush((0, 255, 127, 100)))

        if self.curImage is not None:
            self.curImage.gradient = self.plot.getHistogramWidget().gradient.saveState()
            self.curImage.levels = self.plot.getHistogramWidget().getLevels()
            if self.plot.axes.get('t', None) is not None:
                self.curImage.time = self.plot.timeLine.value()

            self.curImage.savedGradient = self.gradient_isocurve.saveState()
            self.curImage.remove_isocurves()

        self.curImage = image
        image.update_slice_table(self.table_slice)
        self.sync_buttons()

        if image.gradient is not None:
            self.plot.getHistogramWidget().gradient.restoreState(image.gradient)

        if image.valName is not None:
            image.display_image()
        else:
            self.plot.clear()

        if image.levels is not None:
            self.plot.setLevels(*image.levels)
        if image.time is not None and self.plot.axes['t'] is not None:
            self.plot.timeLine.setValue(image.time)
            self.plot.timeLineChanged()

        if image.savedGradient is not None:
            self.gradient_isocurve.restoreState(image.savedGradient)
        self.table_isocurve.setRowCount(0)
        image.init_isocurves()
开发者ID:bencorbett90,项目名称:Graph,代码行数:55,代码来源:imagetab.py

示例13: setPlot

    def setPlot(self, plot):
        self.plot = plot
        self.spi = pg.ScatterPlotItem(size=10,
                                      pen=pg.mkPen(None),
                                      brush=pg.mkBrush(255, 255, 255, 255))
        self.spi2 = pg.ScatterPlotItem(size=10,
                                      pen=pg.mkPen(None),
                                      brush=pg.mkBrush(255, 0, 0, 255))

        self.plot.setXRange(0, 1024)
        self.plot.setYRange(0, 768)
开发者ID:freakimkaefig,项目名称:itt_lamm_lechler,代码行数:11,代码来源:drawPath.py

示例14: test_scatterplotitem

def test_scatterplotitem():
    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())

    # test SymbolAtlas accepts custom symbol
    s = pg.ScatterPlotItem()
    symbol = QtGui.QPainterPath()
    symbol.addEllipse(QtCore.QRectF(-0.5, -0.5, 1, 1))
    s.addPoints([{'pos': [0,0], 'data': 1, 'symbol': symbol}])

    for i, pxMode in enumerate([True, False]):
        for j, useCache in enumerate([True, False]):
            s = pg.ScatterPlotItem()
            s.opts['useCache'] = useCache
            plot.addItem(s)
            s.setData(x=np.array([10,40,20,30])+i*100, y=np.array([40,60,10,30])+j*100, pxMode=pxMode)
            s.addPoints(x=np.array([60, 70])+i*100, y=np.array([60, 70])+j*100, size=[20, 30])

            # Test uniform spot updates
            s.setSize(10)
            s.setBrush('r')
            s.setPen('g')
            s.setSymbol('+')
            app.processEvents()

            # Test list spot updates
            s.setSize([10] * 6)
            s.setBrush([pg.mkBrush('r')] * 6)
            s.setPen([pg.mkPen('g')] * 6)
            s.setSymbol(['+'] * 6)
            s.setPointData([s] * 6)
            app.processEvents()

            # Test array spot updates
            s.setSize(np.array([10] * 6))
            s.setBrush(np.array([pg.mkBrush('r')] * 6))
            s.setPen(np.array([pg.mkPen('g')] * 6))
            s.setSymbol(np.array(['+'] * 6))
            s.setPointData(np.array([s] * 6))
            app.processEvents()

            # Test per-spot updates
            spot = s.points()[0]
            spot.setSize(20)
            spot.setBrush('b')
            spot.setPen('g')
            spot.setSymbol('o')
            spot.setData(None)
            app.processEvents()

    plot.clear()
开发者ID:grg2rsr,项目名称:ILTIS,代码行数:53,代码来源:test_ScatterPlotItem.py

示例15: generatePicture

 def generatePicture(self):
     self.picture = QtGui.QPicture()
     p = QtGui.QPainter(self.picture)
     p.setPen(pg.mkPen('w'))
     w = (self.data[1][0] - self.data[0][0]) / 3.
     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('r'))
         else:
             p.setBrush(pg.mkBrush('g'))
         p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
     p.end()
开发者ID:freeitaly,项目名称:Trading-System,代码行数:13,代码来源:customGraphicsItem.py


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