How to use the pyqtgraph.mkPen 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 biolab / orange3 / Orange / widgets / evaluate / owcalibrationplot.py View on Github external
if probs.size:
            xmin, xmax = probs.min(), probs.max()
            x = np.linspace(xmin, xmax, 100)
            if xmax != xmin:
                f = gaussian_smoother(probs, ytrue, sigma=0.15 * (xmax - xmin))
                observed = f(x)
            else:
                observed = np.full(100, xmax)
        else:
            x = np.array([])
            observed = np.array([])

        curve = Curve(x, observed)
        curve_item = pg.PlotDataItem(
            x, observed, pen=pg.mkPen(self.colors[clf_idx], width=1),
            shadowPen=pg.mkPen(self.colors[clf_idx].lighter(160), width=2),
            symbol="+", symbolSize=4,
            antialias=True
        )

        rh = 0.025
        rug_x = np.c_[probs, probs]
        rug_x_true = rug_x[ytrue].ravel()
        rug_x_false = rug_x[~ytrue].ravel()

        rug_y_true = np.ones_like(rug_x_true)
        rug_y_true[1::2] = 1 - rh
        rug_y_false = np.zeros_like(rug_x_false)
        rug_y_false[1::2] = rh

        rug1 = pg.PlotDataItem(
            rug_x_false, rug_y_false, pen=self.colors[clf_idx],
github pyqtgraph / pyqtgraph / examples / ScatterPlot.py View on Github external
## This is the slowest case, since all spots must be completely re-drawn
## every time because their apparent transformation may have changed.

s3 = pg.ScatterPlotItem(pxMode=False)   ## Set pxMode=False to allow spots to transform with the view
spots3 = []
for i in range(10):
    for j in range(10):
        spots3.append({'pos': (1e-6*i, 1e-6*j), 'size': 1e-6, 'pen': {'color': 'w', 'width': 2}, 'brush':pg.intColor(i*10+j, 100)})
s3.addPoints(spots3)
w3.addItem(s3)
s3.sigClicked.connect(clicked)


## Test performance of large scatterplots

s4 = pg.ScatterPlotItem(size=10, pen=pg.mkPen(None), brush=pg.mkBrush(255, 255, 255, 20))
pos = np.random.normal(size=(2,10000), scale=1e-9)
s4.addPoints(x=pos[0], y=pos[1])
w4.addItem(s4)
s4.sigClicked.connect(clicked)



## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
github flika-org / flika / plugins / detect_puffs / average_origin.py View on Github external
def drawRedOverlay(self):
        puffs=[pt.data() for pt in self.s1.points() if self.roi.contains(pt.pos().x(),pt.pos().y())]
        times=[[puff.kinetics['t_start'],puff.kinetics['t_end']] for puff in puffs]
        data=g.m.currentTrace.rois[g.m.currentTrace.get_roi_index(self.roi)]['p1trace'].getData()[1]
        
        x=np.array([np.arange(*times[i]) for i in np.arange(len(times))])
        traces=[data[time] for time in x]
        y=np.array(traces)
        for i in np.arange(len(self.redTraces)):
            g.m.currentTrace.p1.removeItem(self.redTraces[i][0])
        self.redTraces=[]
        for i in np.arange(len(x)):
            self.redTraces.append([g.m.currentTrace.p1.plot(x[i],y[i],pen=pg.mkPen('r')),puffs[i]])
        currentPuff=self.puffs.getPuff()
        if currentPuff in puffs:
            idx=puffs.index(currentPuff)
            self.redTraces[idx][0].setPen(pg.mkPen(color='r',width=3))
github biolab / orange3-prototypes / orangecontrib / prototypes / widgets / owlinearprojection.py View on Github external
dtype=object)

            brush_data[~subset_mask] = QtGui.QBrush(Qt.NoBrush)

        if self._selection_mask is not None:
            assert self._selection_mask.shape == (len(self.data),)
            if mask is not None:
                selection_mask = self._selection_mask[mask]
            else:
                selection_mask = self._selection_mask

            if isinstance(pen_data, QtGui.QPen):
                pen_data = numpy.array([pen_data] * selection_mask.size,
                                       dtype=object)

            pen_data[selection_mask] = pg.mkPen((200, 200, 0, 150), width=4)
        return pen_data, brush_data
github tridesclous / tridesclous / tridesclous / gui / waveformhistviewer.py View on Github external
for k in visibles:
            
            
            median, chans = self.controller.get_waveform_centroid(k, 'median', channels=common_channels)
            if median is None:
                continue
            
            if self.params['data']=='waveforms':
                y = median.T.flatten()
            else:
                sel = labels[ind_keep] == k
                y = np.median(data_kept[sel, :], axis=0)
            color = self.controller.qcolors.get(k, QT.QColor( 'white'))
            
            curve = pg.PlotCurveItem(x=indexes0, y=y, pen=pg.mkPen(color, width=2))
            self.plot.addItem(curve)
            self.curves.append(curve)
            #~ curve.setData()
            #~ curve.setPen()
            #~ curve.show()
        
        if self.params['display_threshold'] and self.params['data']=='waveforms' :
            self.thresh_line.show()
        else:
            self.thresh_line.hide()
        
        
        #~ if self._x_range is None:
        if True:
            self._x_range = 0, indexes0[-1] #hist2d.shape[1]
            self._y_range = bin_min, bin_max
github fossasia / pslab-desktop / psl_res / GUI / E_MISCELLANEOUS / B / calibrator.py View on Github external
for a in range(8):
			item = QtGui.QTableWidgetItem()
			self.valueTable.setItem(0,a,item)
			item.setText('.')

		self.plot=self.add2DPlot(self.plot_area)
		labelStyle = {'color': 'rgb(255,255,255)', 'font-size': '11pt'}
		self.plot.setLabel('left','Read Voltages -->', units='V',**labelStyle)
		self.plot.setLabel('bottom','Actual Voltage -->', units='V',**labelStyle)
		#self.plot.setYRange(-.1,.1)
		self.curves={}

		self.curves['INL']=self.addCurve(self.plot,pen=pg.mkPen([255,255,255], width=1),name='INL')
		item = self.addLabel('INL',[255,255,255]);	self.curves['INL'].curve.setClickable(True);	self.curves['INL'].sigClicked.connect(functools.partial(self.selectItem,item))

		self.curves['PV3']=self.addCurve(self.plot,pen=pg.mkPen([255,255,255], width=1),name='PV3')
		item = self.addLabel('PV3',[255,255,255]); self.curves['PV3'].curve.setClickable(True);	self.curves['PV3'].sigClicked.connect(functools.partial(self.selectItem,item))

		
		for a in self.INPUTS:
			self.curves[a]={}
			if self.I.analogInputSources[a].gainEnabled:
				for b in range(8):
					col=QtGui.QColor(random.randint(20,255),random.randint(20,255),random.randint(20,255))
					name = '%s:%dx'%(a,self.I.gain_values[b])
					self.curves[a][b]=self.addCurve(self.plot,pen=pg.mkPen(col, width=1),name=name)
					item = self.addLabel(name,col);	self.curves[a][b].curve.setClickable(True);	self.curves[a][b].sigClicked.connect(functools.partial(self.selectItem,item))
			else:
				col=QtGui.QColor(random.randint(20,255),random.randint(20,255),random.randint(20,255))
				name = '%s:1x'%(a)
				self.curves[a][0]=self.addCurve(self.plot,pen=pg.mkPen(col, width=1),name='%s:1x'%(a))
				item = self.addLabel(name,col);	self.curves[a][0].curve.setClickable(True);	self.curves[a][0].sigClicked.connect(functools.partial(self.selectItem,item))
github not-matt / Systematic-LEDs / python / main.py View on Github external
# Mel filterbank plot
        fft_plot = graph_layout.addPlot(title='Filterbank Output', colspan=3)
        fft_plot.setRange(yRange=[-0.1, 1.2])
        fft_plot.disableAutoRange(axis=pg.ViewBox.YAxis)
        x_data = np.array(range(1, config.settings["devices"][self.board]["configuration"]["N_FFT_BINS"] + 1))
        self.board_tabs_widgets[board]["mel_curve"] = pg.PlotCurveItem()
        self.board_tabs_widgets[board]["mel_curve"].setData(x=x_data, y=x_data*0)
        fft_plot.addItem(self.board_tabs_widgets[board]["mel_curve"])
        # Visualization plot
        graph_layout.nextRow()
        led_plot = graph_layout.addPlot(title='Visualization Output', colspan=3)
        led_plot.setRange(yRange=[-5, 260])
        led_plot.disableAutoRange(axis=pg.ViewBox.YAxis)
        # Pen for each of the color channel curves
        r_pen = pg.mkPen((255, 30, 30, 200), width=4)
        g_pen = pg.mkPen((30, 255, 30, 200), width=4)
        b_pen = pg.mkPen((30, 30, 255, 200), width=4)
        # Color channel curves
        self.board_tabs_widgets[board]["r_curve"] = pg.PlotCurveItem(pen=r_pen)
        self.board_tabs_widgets[board]["g_curve"] = pg.PlotCurveItem(pen=g_pen)
        self.board_tabs_widgets[board]["b_curve"] = pg.PlotCurveItem(pen=b_pen)
        # Define x data
        x_data = np.array(range(1, config.settings["devices"][self.board]["configuration"]["N_PIXELS"] + 1))
        self.board_tabs_widgets[board]["r_curve"].setData(x=x_data, y=x_data*0)
        self.board_tabs_widgets[board]["g_curve"].setData(x=x_data, y=x_data*0)
        self.board_tabs_widgets[board]["b_curve"].setData(x=x_data, y=x_data*0)
        # Add curves to plot
        led_plot.addItem(self.board_tabs_widgets[board]["r_curve"])
        led_plot.addItem(self.board_tabs_widgets[board]["g_curve"])
        led_plot.addItem(self.board_tabs_widgets[board]["b_curve"])

        # Set up button layout
github lutraconsulting / qgis-crayfish-plugin / crayfish / gui / plot_1d_widget.py View on Github external
def add_timeseries_plot(self, geom_pt, clr,searchRadius):

        ds_group_index = self.current_dataset_group()

        x, y = timeseries_plot_data(self.layer, ds_group_index, geom_pt,searchRadius)
        self.plot.getAxis('left').setLabel(self.dataset_group_name(ds_group_index))
        self.plot.legend.setVisible(False)

        valid_plot = not all(map(math.isnan, y))
        if not valid_plot:
            return

        pen = pyqtgraph.mkPen(color=clr, width=2, cosmetic=True)
        return self.plot.plot(x=x, y=y, connect='finite', pen=pen)
github shanet / Osprey / desktop / qGraph.py View on Github external
def createDatasetForDisplay(self, display):
    plotData = PlotDataItem(name=display['label'])

    if 'color' in display:
      plotData.setPen(mkPen({'color': display['color']}))

    return {
      'plotData': plotData,
      'points': numpy.zeros((constants.NUMPY_ARRAY_SIZE, 2)),
    }