Python pyqtgraph.mkColor() Examples

The following are 12 code examples of pyqtgraph.mkColor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyqtgraph , or try the search function .
Example #1
Source File: tab_covariance.py    From kite with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent_plot):
        KiteSubplot.__init__(self, parent_plot)

        self.structure = pg.PlotDataItem(
            antialias=True,
            pen=pen_covariance_active)
        self.variance = self.VarianceLine(
            pen=pen_variance,
            angle=0, movable=True, hoverPen=pen_variance_highlight,
            label='Variance: {value:.5f}',
            labelOpts={'position': .975,
                       'anchors': ((1., 0.), (1., 1.)),
                       'color': pg.mkColor(255, 255, 255, 155)})
        self.plot.setLabels(
            bottom=('Distance', 'm'),
            left='Variance (m<sup>2</sup>)')

        self.addItem(self.structure)
        self.addItem(self.variance)
        self.variance.sigPositionChangeFinished.connect(
            self.changeVariance) 
Example #2
Source File: plot.py    From qspectrumanalyzer with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, layout):
        if not isinstance(layout, pg.GraphicsLayoutWidget):
            raise ValueError("layout must be instance of pyqtgraph.GraphicsLayoutWidget")

        self.layout = layout

        self.main_curve = True
        self.main_color = pg.mkColor("y")
        self.persistence = False
        self.persistence_length = 5
        self.persistence_decay = "exponential"
        self.persistence_color = pg.mkColor("g")
        self.persistence_data = None
        self.persistence_curves = None
        self.peak_hold_max = False
        self.peak_hold_max_color = pg.mkColor("r")
        self.peak_hold_min = False
        self.peak_hold_min_color = pg.mkColor("b")
        self.average = False
        self.average_color = pg.mkColor("c")
        self.baseline = False
        self.baseline_color = pg.mkColor("m")

        self.create_plot() 
Example #3
Source File: tab_covariance.py    From kite with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent_plot):
        KiteSubplot.__init__(self, parent_plot)
        self.plot.setLabels(
            bottom=('Distance', 'm'),
            left='Covariance (m<sup>2</sup>)')

        self.cov_spectral = pg.PlotDataItem(antialias=True)
        self.cov_spectral.setZValue(10)

        self.cov_spatial = pg.PlotDataItem(antialias=True)

        self.cov_model = pg.PlotDataItem(
            antialias=True,
            pen=pen_covariance_model)

        self.variance = self.VarianceLine(
            pen=pen_variance,
            angle=0, movable=True, hoverPen=pen_variance_highlight,
            label='Variance: {value:.5f}',
            labelOpts={'position': .975,
                       'anchors': ((1., 0.), (1., 1.)),
                       'color': pg.mkColor(255, 255, 255, 155)})
        self.variance.setToolTip('Move to change variance')
        self.variance.sigPositionChangeFinished.connect(self.setVariance)

        self.addItem(self.cov_spectral)
        self.addItem(self.cov_spatial)
        self.addItem(self.cov_model)
        self.addItem(self.variance)
        # self.cov_lin_pow = pg.PlotDataItem(antialias=True,
        #                                    pen=pen_green_dash)
        # self.addItem(self.cov_lin_pow)

        self.legend = pg.LegendItem(offset=(0., .5))

        self.legend.setParentItem(self.plot.graphicsItem())
        self.legend.addItem(self.cov_model, '') 
Example #4
Source File: play.py    From simulator with GNU General Public License v3.0 5 votes vote down vote up
def draw_buffer(self):
        self.buff_win = pg.GraphicsLayoutWidget()
        self.buff_win.setWindowTitle('Buffer Status')
        self.buff_win.resize(800, 700)

        self.total_peers = self.number_of_monitors + self.number_of_peers + self.number_of_malicious
        self.p4 = self.buff_win.addPlot()
        self.p4.showGrid(x=True, y=True, alpha=100)   # To show grid lines across x axis and y axis
        leftaxis = self.p4.getAxis('left')  # get left axis i.e y axis
        leftaxis.setTickSpacing(5, 1)    # to set ticks at a interval of 5 and grid lines at 1 space

        # Get different colors using matplotlib library
        if self.total_peers < 8:
            colors = cm.Set2(np.linspace(0, 1, 8))
        elif self.total_peers < 12:
            colors = cm.Set3(np.linspace(0, 1, 12))
        else:
            colors = cm.rainbow(np.linspace(0, 1, self.total_peers+1))
        self.QColors = [pg.hsvColor(color[0], color[1], color[2], color[3])
                        for color in colors]   # Create QtColors, each color would represent a peer

        self.Data = []  # To represent buffer out  i.e outgoing data from buffer
        self.OutData = []   # To represent buffer in i.e incoming data in buffer

        # a single line would reperesent a single color or peer, hence we would not need to pass a list of brushes
        self.lineIN = [None]*self.total_peers
        for ix in range(self.total_peers):
            self.lineIN[ix] = self.p4.plot(pen=(None), symbolBrush=self.QColors[ix], name='IN', symbol='o', clear=False)
            self.Data.append(set())
            self.OutData.append(set())

        # similiarly one line per peer to represent outgoinf data from buffer
        self.lineOUT = self.p4.plot(pen=(None), symbolBrush=mkColor('#CCCCCC'), name='OUT', symbol='o', clear=False)
        self.p4.setRange(xRange=[0, self.total_peers], yRange=[0, self.get_buffer_size()])
        self.buff_win.show()    # To actually show create window

        self.buffer_order = {}
        self.buffer_index = 0
        self.buffer_labels = []
        self.lastUpdate = pg.ptime.time()
        self.avgFps = 0.0 
Example #5
Source File: play.py    From simulator with GNU General Public License v3.0 5 votes vote down vote up
def plot_clr(self):
        self.clrs_per_round = []
        self.clr_win = pg.GraphicsLayoutWidget()
        self.clr_win.setWindowTitle('Chunk Loss Ratio')
        self.clr_win.resize(800, 700)
        self.clr_figure = self.clr_win.addPlot()
        self.clr_figure.addLegend()
        self.lineCLR = self.clr_figure.plot(pen=(None), symbolBrush=mkColor(
            '#000000'), name="CLR", symbol='o', clear=True)
        self.clr_figure.setRange(xRange=[0, self.number_of_rounds], yRange=[0, 1])
        self.clrData = [[], []]  # 2D list to store both the x and y coordinates
        self.clr_win.show() 
Example #6
Source File: charts.py    From Quantdom with Apache License 2.0 5 votes vote down vote up
def __init__(self, parent=None, digits=0, color=None, opacity=1, **kwargs):
        super().__init__(parent)
        self.parent = parent
        self.opacity = opacity
        self.label_str = ''
        self.digits = digits
        self.quotes_count = len(Quotes) - 1
        if isinstance(color, QtGui.QPen):
            self.bg_color = color.color()
            self.fg_color = pg.mkColor('#ffffff')
        elif isinstance(color, list):
            self.bg_color = {'>0': color[0].color(), '<0': color[1].color()}
            self.fg_color = pg.mkColor('#ffffff')
        self.setFlag(self.ItemIgnoresTransformations) 
Example #7
Source File: OWAnnotateProjection.py    From orange3-bioinformatics with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, view_box, x, y, text, tooltip):
        bg_color = QColor(Qt.white)
        bg_color.setAlpha(200)
        color = QColor(Qt.black)
        super().__init__(text, pg.mkColor(color), fill=pg.mkBrush(bg_color))
        self._x = x
        self._y = y
        self._view_box = view_box
        self._view_box.sigStateChanged.connect(self.center)
        self.textItem.setToolTip(tooltip)
        self.setPos(x, y)
        self.center() 
Example #8
Source File: OWAnnotateProjection.py    From orange3-bioinformatics with GNU General Public License v3.0 5 votes vote down vote up
def update_reference_coordinates(self):
        points = self.master.get_coordinates_reference_data()
        if points is None:
            return
        if self.ref_scatterplot_item is None:
            color = pg.mkColor(200, 200, 200)
            pen, brush = pg.mkPen(color=color), pg.mkBrush(color=color)
            size = OWScatterPlotBase.MinShapeSize + 3
            self.ref_scatterplot_item = pg.ScatterPlotItem(x=points[0], y=points[1], pen=pen, brush=brush, size=size)
            self.plot_widget.addItem(self.ref_scatterplot_item)
        else:
            self.ref_scatterplot_item.setData(x=points[0], y=points[1]) 
Example #9
Source File: __init__.py    From finplot with MIT License 5 votes vote down vote up
def brighten(color, f):
    if not color:
        return color
    return pg.mkColor(color).lighter(f*100) 
Example #10
Source File: test_parametertypes.py    From tf-pose with Apache License 2.0 4 votes vote down vote up
def test_types():
    paramSpec = [
        dict(name='float', type='float'),
        dict(name='int', type='int'),
        dict(name='str', type='str'),
        dict(name='list', type='list', values=['x','y','z']),
        dict(name='dict', type='list', values={'x':1, 'y':3, 'z':7}),
        dict(name='bool', type='bool'),
        dict(name='color', type='color'),
    ]
    
    param = pt.Parameter.create(name='params', type='group', children=paramSpec)
    tree = pt.ParameterTree()
    tree.setParameters(param)

    all_objs = {
        'int0': 0, 'int':7, 'float': -0.35, 'bigfloat': 1e129, 'npfloat': np.float(5), 
        'npint': np.int(5),'npinf': np.inf, 'npnan': np.nan, 'bool': True, 
        'complex': 5+3j, 'str': 'xxx', 'unicode': asUnicode('µ'), 
        'list': [1,2,3], 'dict': {'1': 2}, 'color': pg.mkColor('k'), 
        'brush': pg.mkBrush('k'), 'pen': pg.mkPen('k'), 'none': None
    }
    if hasattr(QtCore, 'QString'):
        all_objs['qstring'] = QtCore.QString('xxxµ')

    # float
    types = ['int0', 'int', 'float', 'bigfloat', 'npfloat', 'npint', 'npinf', 'npnan', 'bool']
    check_param_types(param.child('float'), float, float, 0.0, all_objs, types)

    # int
    types = ['int0', 'int', 'float', 'bigfloat', 'npfloat', 'npint', 'bool']
    inttyps = int if sys.version[0] >= '3' else (int, long) 
    check_param_types(param.child('int'), inttyps, int, 0, all_objs, types)
    
    # str  (should be able to make a string out of any type)
    types = all_objs.keys()
    strtyp = str if sys.version[0] >= '3' else unicode
    check_param_types(param.child('str'), strtyp, asUnicode, '', all_objs, types)
    
    # bool  (should be able to make a boolean out of any type?)
    types = all_objs.keys()
    check_param_types(param.child('bool'), bool, bool, False, all_objs, types)

    # color
    types = ['color', 'int0', 'int', 'float', 'npfloat', 'npint', 'list']
    init = QtGui.QColor(128, 128, 128, 255)
    check_param_types(param.child('color'), QtGui.QColor, pg.mkColor, init, all_objs, types) 
Example #11
Source File: traceviewer.py    From tridesclous with MIT License 4 votes vote down vote up
def initialize_plot(self):
        self.viewBox = MyViewBox()
        self.plot = pg.PlotItem(viewBox=self.viewBox)
        self.graphicsview.setCentralItem(self.plot)
        self.plot.hideButtons()
        self.plot.showAxis('left', False)
        
        self.viewBox.gain_zoom.connect(self.gain_zoom)
        self.viewBox.xsize_zoom.connect(self.xsize_zoom)
        
        self.visible_channels = np.zeros(self.controller.nb_channel, dtype='bool')
        self.max_channel = min(16, self.controller.nb_channel)
        #~ self.max_channel = min(5, self.controller.nb_channel)
        if self.controller.nb_channel>self.max_channel:
            self.visible_channels[:self.max_channel] = True
            self.scroll_chan.show()
            self.scroll_chan.setMinimum(0)
            self.scroll_chan.setMaximum(self.controller.nb_channel-self.max_channel)
            self.scroll_chan.setPageStep(self.max_channel)
        else:
            self.visible_channels[:] = True
            self.scroll_chan.hide()
            
        self.signals_curve = pg.PlotCurveItem(pen='#7FFF00', connect='finite')
        self.plot.addItem(self.signals_curve)

        self.scatter = pg.ScatterPlotItem(size=10, pxMode = True)
        self.plot.addItem(self.scatter)
        self.scatter.sigClicked.connect(self.scatter_item_clicked)
        
        self.channel_labels = []
        self.threshold_lines =[]
        for i, chan_name in enumerate(self.controller.channel_names):
            #TODO label channels
            label = pg.TextItem('{}: {}'.format(i, chan_name), color='#FFFFFF', anchor=(0, 0.5), border=None, fill=pg.mkColor((128,128,128, 180)))
            self.plot.addItem(label)
            self.channel_labels.append(label)
        
        
        for i in range(self.max_channel):
            tc = pg.InfiniteLine(angle = 0., movable = False, pen = pg.mkPen(color=(128,128,128, 120)))
            tc.setPos(0.)
            self.threshold_lines.append(tc)
            self.plot.addItem(tc)
            tc.hide()
        
        pen = pg.mkPen(color=(128,0,128, 120), width=3, style=QT.Qt.DashLine)
        self.selection_line = pg.InfiniteLine(pos = 0., angle=90, movable=False, pen = pen)
        self.plot.addItem(self.selection_line)
        self.selection_line.hide()
        
        self._initialize_plot()
        
        self.gains = None
        self.offsets = None 
Example #12
Source File: silhouette.py    From tridesclous with MIT License 4 votes vote down vote up
def refresh(self):
        self.plot.clear()
        silhouette_values = self.controller.spike_silhouette
        if silhouette_values is None:
            return
        
        if silhouette_values.shape != self.controller.spike_label.shape:
            return
        
        silhouette_avg = np.mean(silhouette_values)
        silhouette_by_labels = {}
        labels = self.controller.spike_label
        labels_list = np.unique(labels)
        for k in labels_list:
            v = silhouette_values[k==labels]
            v.sort()
            silhouette_by_labels[k] = v
        
        
        self.vline = pg.InfiniteLine(pos=silhouette_avg, angle = 90, movable = False, pen = '#FF0000')
        self.plot.addItem(self.vline)
        
        y_lower = 10
        cluster_visible = self.controller.cluster_visible
        visibles = [c for c, v in self.controller.cluster_visible.items() if v and c>=0]
        
        for k in visibles:
            if k not in silhouette_by_labels:
                continue
            v = silhouette_by_labels[k]
            
            color = self.controller.qcolors[k]
            color2 = QT.QColor(color)
            color2.setAlpha(self.alpha)
            
            y_upper = y_lower + v.size
            y_vect = np.arange(y_lower, y_upper)
            curve1 = pg.PlotCurveItem(np.zeros(v.size), y_vect, pen=color)
            curve2 = pg.PlotCurveItem(v, y_vect, pen=color)
            self.plot.addItem(curve1)
            self.plot.addItem(curve2)
            fill = pg.FillBetweenItem(curve1=curve1, curve2=curve2, brush=color2)
            self.plot.addItem(fill)
            
            txt = pg.TextItem( text='{}'.format(k), color='#FFFFFF', anchor=(0, 0.5), border=None)#, fill=pg.mkColor((128,128,128, 180)))
            self.plot.addItem(txt)
            txt.setPos(0, (y_upper+y_lower)/2.)
            
            y_lower = y_upper + 10

        
        self.plot.setXRange(-.5, 1.)
        self.plot.setYRange(0,y_lower)