How to use the pyqtgraph.mkBrush function in pyqtgraph

To help you get started, we’ve selected a few pyqtgraph examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flika-org / flika / plugins / detect_puffs / threshold_cluster.py View on Github external
self.sitesVisible=False
        self.trashVisible=False
        self.currentPuff_spinbox.puffidx=-1
        
        
        self.s1=pg.ScatterPlotItem(size=5, pen=pg.mkPen(None)) #PUFFS
        self.data_window.imageview.addItem(self.s1)
        for puff in self.puffs.puffs:
            x=puff.kinetics['x']
            y=puff.kinetics['y']
            self.s1.addPoints(pos=[[x,y]],data=puff, brush=pg.mkBrush(puff.color),pen=pg.mkPen([0,0,0,255]))
        self.s1.sigClicked.connect(self.clicked)
        self.s2=pg.ScatterPlotItem(size=5,  brush=pg.mkBrush(0, 255, 0, 255),pen=pg.mkPen([0,0,0,255])) #SITES
        self.s2.sigClicked.connect(self.clickedSite)
        self.s2.addPoints(pos=[site.pos for site in self.sites],data=self.sites)
        self.s3=pg.ScatterPlotItem(size=5,  brush=pg.mkBrush(0, 255, 255, 255),pen=pg.mkPen([0,0,0,255])) #TRASH
        self.s3.sigClicked.connect(self.clickedTrash)
        self.s4=pg.ScatterPlotItem(size=10, brush=pg.mkBrush(255, 255, 255, 120),pen=pg.mkPen([0,0,0,255]))
        view = pg.GraphicsLayoutWidget()
        self.d4.addWidget(view)
        self.scatter_viewbox=ScatterViewBox()
        self.scatterPlot=view.addPlot(viewBox=self.scatter_viewbox)
        self.scatter_viewbox.drawFinishedSignal.connect(self.lasso_puffs)
        self.scatter_viewbox.EnterPressedSignal.connect(self.reset_scatter_colors)
        self.scatterPlot.addItem(self.s4)   
        self.lastClickedScatterPt = []
        self.s4.sigClicked.connect(self.clickedScatter)
        

        for puff in self.trash:
            x=puff.kinetics['x']
            y=puff.kinetics['y']
github biolab / orange3-prototypes / orangecontrib / prototypes / widgets / owlinearprojection.py View on Github external
if color_var.is_continuous:
                color_data = plotutils.continuous_colors(color_data)
            else:
                color_data = plotutils.discrete_colors(
                    color_data, len(color_var.values)
                )
            if mask is not None:
                color_data = color_data[mask]

            pen_data = numpy.array(
                [pg.mkPen((r, g, b), width=1.5)
                 for r, g, b in color_data * 0.8],
                dtype=object)

            brush_data = numpy.array(
                [pg.mkBrush((r, g, b, self.alpha_value))
                 for r, g, b in color_data],
                dtype=object)
        else:
            color = QtGui.QColor(Qt.darkGray)
            pen_data = QtGui.QPen(color, 1.5)
            pen_data.setCosmetic(True)
            color = QtGui.QColor(Qt.lightGray)
            color.setAlpha(self.alpha_value)
            brush_data = QtGui.QBrush(color)

        if self._subset_mask is not None:
            assert self._subset_mask.shape == (len(self.data),)
            if mask is not None:
                subset_mask = self._subset_mask[mask]
            else:
                subset_mask = self._subset_mask
github florisvb / multi_tracker / multi_tracker_analysis / trajectory_viewer_gui.py View on Github external
# undo      
        undo_btn = QtGui.QPushButton('undo last action')
        undo_btn.pressed.connect(self.undo)
        self.layout.addWidget(undo_btn, 7, 0)
        
        
        self.p1 = pg.PlotWidget(title="Basic array plotting")
        self.p1.enableAutoRange('xy', False)
        self.layout.addWidget(self.p1, 1, 1)
        if self.config is not None:
            print '**** Sensory stimulus: ', self.config.sensory_stimulus_on
            for r, row in enumerate(self.config.sensory_stimulus_on):
                v1 = pg.PlotDataItem([self.config.sensory_stimulus_on[r][0],self.config.sensory_stimulus_on[r][0]], [0,10])
                v2 = pg.PlotDataItem([self.config.sensory_stimulus_on[r][-1],self.config.sensory_stimulus_on[r][-1]], [0,10])
                f12 = pg.FillBetweenItem(curve1=v1, curve2=v2, brush=pg.mkBrush('r'))
                self.p1.addItem(f12)
        
        self.p2 = pg.PlotWidget()
        self.layout.addWidget(self.p2, 0, 1)
        
        lr = pg.LinearRegionItem(values=self.troi)
        f = 'update_time_region'
        lr.sigRegionChanged.connect(self.__getattribute__(f))
        self.p1.addItem(lr)
        self.draw_timeseries_vlines_for_interesting_timepoints()
        
        self.current_time_vline = pg.InfiniteLine(angle=90, movable=False)
        self.p1.addItem(self.current_time_vline, ignoreBounds=True)
        self.current_time_vline.setPos(0)
        pen = pg.mkPen((255,255,255), width=2)
        self.current_time_vline.setPen(pen)
github acconeer / acconeer-python-exploration / examples / services / power_bins.py View on Github external
def setup(self, win):
        win.setWindowTitle("Acconeer power bins example")

        self.plot = win.addPlot()
        self.plot.setMenuEnabled(False)
        self.plot.showGrid(x=True, y=True)
        self.plot.setLabel("bottom", "Depth (m)")
        self.plot.setLabel("left", "Amplitude")

        self.curves = []
        for i, _ in enumerate(self.sensor_config.sensor):
            curve = self.plot.plot(
                pen=utils.pg_pen_cycler(i),
                symbol="o",
                symbolPen="k",
                symbolBrush=pg.mkBrush(utils.color_cycler(i)),
            )
            self.curves.append(curve)

        self.smooth_max = utils.SmoothMax(self.sensor_config.update_rate)
github swharden / diyECG-1opAmp / software / go.py View on Github external
def __init__(self, parent=None):
        pyqtgraph.setConfigOption('background', 'w') #before loading widget
        super(ExampleApp, self).__init__(parent)
        self.setupUi(self)
        self.grECG.plotItem.showGrid(True, True, 0.7)
        self.btnSave.clicked.connect(self.saveFig)
        self.btnSite.clicked.connect(self.website)
        stamp="DIY ECG by Scott Harden"
        self.stamp = pyqtgraph.TextItem(stamp,anchor=(-.01,1),color=(150,150,150),
                                        fill=pyqtgraph.mkBrush('w'))
        self.ear = swhear.Ear(chunk=int(100)) # determines refresh rate
        # optionally you can manually set the audio input device to use like this:
        # self.ear = swhear.Ear(chunk=int(100), device=5) # use audio input device 5
        if len(self.ear.valid_input_devices()):
            self.ear.stream_start()
            self.lblDevice.setText(self.ear.msg)
            self.update()
github ZhuangLab / storm-control / storm_control / zee_calibrator / plot.py View on Github external
def plotStageQPD(self, stage, qpd, slope, offset):
        qpd_min = numpy.min(qpd)
        qpd_max = numpy.max(qpd)
        self.viewbox.setRange(yRange = (1.1*qpd_min, 1.1*qpd_max))
        self.plot(stage, qpd,
                  pen = None,
                  symbol = 'o',
                  symbolPen = pyqtgraph.mkPen(0,0,0),
                  symbolBrush = pyqtgraph.mkBrush(255,255,255),
                  symbolSize = 6)

        x_vals = numpy.array([-1.0, 1.0])
        y_vals = (x_vals - offset)/slope
        self.plot(x_vals, y_vals, pen = pyqtgraph.mkPen(0,0,0))

        self.static_text = QtGui.QStaticText("slope = {0:.3f} au/um".format(-1.0/slope))
github pyqtgraph / pyqtgraph / examples / verlet_chain / chain.py View on Github external
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
github flika-org / flika / plugins / detect_puffs / gaussianFittingReproducibility.py View on Github external
positions=puff.origin_positions
        else:
            positions=self.runSimulation(puff)
            puff.origin_positions=positions
        # MAKE SCATTER PLOT OF POINTS
        red,green,blue=color
        brush=pg.mkBrush(red, green,blue,50)
        self.points[index] = pg.ScatterPlotItem(size=.01 , pen=pg.mkPen(None), brush=brush)
        self.points[index].setPxMode(False) # size in terms of original image pixels, not screen pixels.
        for pos in positions:
            spots = [{'pos': po, 'data': 1} for po in pos]
            self.points[index].addPoints(spots)
        if self.showPoints.isChecked():
            self.plot.addItem(self.points[index])
        # MAKE SCATTER PLOT OF CIRCLES
        brush=pg.mkBrush(red, green,blue,20)
        self.circles[index]=pg.ScatterPlotItem(size=5, pen=pg.mkPen(None), brush=brush)
        self.circles[index].setPxMode(False) # size in terms of original image pixels, not screen pixels.
        for pos in positions:
            sigma=np.mean([np.std(pos[:,0]),np.std(pos[:,1])]) #take the mean of the standard deviations of the x and y values
            circ=np.column_stack((np.mean(pos[:,0]),np.mean(pos[:,1])))
            spot = [{'pos': circ[0], 'data': 1, 'brush':brush, 'size':4*sigma }]
            self.circles[index].addPoints(spot)
        if self.showCircles.isChecked():
            self.plot.addItem(self.circles[index])
    def togglePoints(self,state):
github physercoe / starquant / source / gui / ui_dataview.py View on Github external
def tickStrings(self, vals, scale, spacing):
        digts = max(0, np.ceil(-np.log10(spacing * scale)))
        return [
            ('{:<8,.%df}' % digts).format(v).replace(',', ' ') for v in vals
        ]


CHART_MARGINS = (0, 0, 20, 10)


class QuotesChart(QtGui.QWidget):
    signal = QtCore.pyqtSignal(Event)

    long_pen = pg.mkPen('#006000')
    long_brush = pg.mkBrush('#00ff00')
    short_pen = pg.mkPen('#600000')
    short_brush = pg.mkBrush('#ff0000')

    zoomIsDisabled = QtCore.pyqtSignal(bool)

    def __init__(self, symbol: str = ""):
        super().__init__()
        self.full_symbol = symbol
        self.data = []
        self.bg = BarGenerator(self.on_bar)
        self.layout = QtGui.QVBoxLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.chart = None
        self.charv = None
        self.load_bar()
        self.plot()
github vnpy / vnpy / vnpy / chart / item.py View on Github external
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)