How to use the pyqtgraph.ScatterPlotItem 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 lneuhaus / pyrpl / pyrpl / trash / module_widgets.py View on Github external
symbol='x',
                                               pen=pg.mkPen(None),
                                               brush=pg.mkBrush(255, 0, 255, 120))
        self.plot_item.addItem(self.points_poles)
        self.points_poles_phase =  pg.ScatterPlotItem(size=20,
                                                      pen=pg.mkPen(None),
                                                      symbol='x',
                                                      brush=pg.mkBrush(255, 0, 255, 120))
        self.plot_item_phase.addItem(self.points_poles_phase)

        self.points_zeros = pg.ScatterPlotItem(size=20,
                                               symbol='o',
                                               pen=pg.mkPen(None),
                                               brush=pg.mkBrush(255, 0, 255, 120))
        self.plot_item.addItem(self.points_zeros)
        self.points_zeros_phase = pg.ScatterPlotItem(size=20,
                                                     pen=pg.mkPen(None),
                                                     symbol='o',
                                                     brush=pg.mkBrush(255, 0, 255, 120))
        self.plot_item_phase.addItem(self.points_zeros_phase)

        self.main_layout.addWidget(self.win)
        self.main_layout.addWidget(self.win_phase)
        self.init_attribute_layout()
        self.second_attribute_layout = QtGui.QVBoxLayout()
        self.attribute_layout.addLayout(self.second_attribute_layout)
        self.third_attribute_layout = QtGui.QVBoxLayout()
        self.attribute_layout.addLayout(self.third_attribute_layout)
        index = 0
        for key, widget in self.attribute_widgets.items():
            index+=1
            if index>3:
github sapphire008 / Python / Pycftool / Pycftool.py View on Github external
p.showGrid(x=True, y=True)
            p.setLabels(left='{}'.format(self.varnames['xdata']), bottom='Index')
            p.addItem(s1)
            p.autoRange()
        elif set(data_list) == set(['xdata', 'ydata']):  # 2D data
            s1 = pg.ScatterPlotItem(size=5)
            s1.addPoints(x=self.xdata, y=self.ydata, pen='k', brush='k')
            self.initialize_display(self.display_groupBox, method='2D')
            p = self.graphicsView.getItem(row=0, col=0)
            p.clear()
            p.showGrid(x=True, y=True)
            p.setLabels(left='{}'.format(self.varnames['ydata']), bottom='{}'.format(self.varnames['xdata']))
            p.addItem(s1)
            p.autoRange()
        elif set(self.availableData) == set(['xdata', 'ydata', 'wdata']):  # 2D data
            s1 = pg.ScatterPlotItem(pxMode=False)  ## Set pxMode=False to allow spots to transform with the view
            spots = []
            for xx, yy, ww in zip(self.xdata, self.ydata, self.wdata):
                spots.append({'pos': (xx, yy), 'size': 5 * ww, 'pen': {'color': None},
                              'brush': (0, 0, 0, 120)})
            s1.addPoints(spots)
            self.initialize_display(self.display_groupBox, method='2D')
            p = self.graphicsView.getItem(row=0, col=0)
            p.clear()
            p.showGrid(x=True, y=True)
            p.setLabels(left='{}'.format(self.varnames['ydata']), bottom='{}'.format(self.varnames['xdata']))
            p.addItem(s1)
            p.autoRange()
        elif set(self.availableData) == set(['xdata', 'ydata', 'zdata']):  # 3D data
            # Set the graphics view to 3D
            spots = gl.GLScatterPlotItem(pos=np.c_[self.xdata, self.ydata, self.zdata],
                                         color=np.tile([1, 1, 1, 0.5], (len(self.xdata), 1)),
github BioDepot / BioDepot-workflow-builder / orange3 / Orange / widgets / visualize / owdistributions.py View on Github external
for ic, a in enumerate(dist):
                        if self.show_prob - 1 != ic and self.show_prob - 1 != len(dist):
                            continue
                        position = -0.333 + ((ic + 0.5) * 0.666 / len(dist))
                        if dsum < 1e-6:
                            continue
                        prob = a / dsum
                        if not 1e-6 < prob < 1 - 1e-6:
                            continue
                        ci = 1.96 * sqrt(prob * (1 - prob) / dsum)
                        item.tooltip += "\n%s: %.3f ± %.3f" % (
                            cvar_values[ic],
                            prob,
                            ci,
                        )
                        mark = pg.ScatterPlotItem()
                        errorbar = pg.ErrorBarItem()
                        pen = QPen(QBrush(QColor(0)), 1)
                        pen.setCosmetic(True)
                        errorbar.setData(
                            x=[i + position],
                            y=[prob],
                            bottom=min(numpy.array([ci]), prob),
                            top=min(numpy.array([ci]), 1 - prob),
                            beam=numpy.array([0.05]),
                            brush=QColor(1),
                            pen=pen,
                        )
                        mark.setData(
                            [i + position],
                            [prob],
                            antialias=True,
github biolab / orange3-network / orangecontrib / network / widgets / graphview.py View on Github external
def update_marks(self):
        if self.scatterplot_marked is None:
            self.scatterplot_marked = pg.ScatterPlotItem([], [])
            self.scatterplot_marked.setZValue(-5)
            self.plot_widget.addItem(self.scatterplot_marked)

        marked = self.master.get_marked_nodes()
        if marked is None:
            self.scatterplot_marked.setData([], [])
            return
        x, y = self.get_coordinates()
        if x is None:  # sanity check; there can be no marked nodes if x is None
            return
        self.scatterplot_marked.setData(
            x[marked], y[marked], size=25,
            pen=pg.mkPen(None), brush=pg.mkBrush("aff"))
github acconeer / acconeer-python-exploration / examples / processing / sparse_speed.py View on Github external
self.est_update_rate,
            tau_decay=0.5,
            tau_grow=0,
            hysteresis=0.2,
        )

        # Rolling speed plot

        self.vel_plot = pg.PlotItem()
        self.vel_plot.setMenuEnabled(False)
        self.vel_plot.setLabel("bottom", "Time (s)")
        self.vel_plot.showGrid(x=True, y=True)
        self.vel_plot.setXRange(-EST_VEL_HISTORY_LENGTH, 0)
        self.vel_max_line = pg.InfiniteLine(angle=0, pen=pg.mkPen("k", width=1))
        self.vel_plot.addItem(self.vel_max_line)
        self.vel_scatter = pg.ScatterPlotItem(size=8)
        self.vel_plot.addItem(self.vel_scatter)

        self.vel_html_fmt = '<span style="color:#000;font-size:24pt;">{:.1f} {}</span>'
        self.vel_text_item = pg.TextItem(anchor=(0.5, 0))
        self.vel_plot.addItem(self.vel_text_item)

        # Sequence speed plot

        self.sequences_plot = pg.PlotItem()
        self.sequences_plot.setMenuEnabled(False)
        self.sequences_plot.setLabel("bottom", "History")
        self.sequences_plot.showGrid(y=True)
        self.sequences_plot.setXRange(-NUM_SAVED_SEQUENCES + 0.5, 0.5)
        tmp = np.flip(np.arange(NUM_SAVED_SEQUENCES) == 0)
        brushes = [pg.mkBrush(utils.color_cycler(n)) for n in tmp]
        self.bar_graph = pg.BarGraphItem(
github spacetelescope / specviz / specviz / core / plots.py View on Github external
plot_container = LinePlot(layer=layer, plot=plot_data_item, **kwargs)

        if plot_container.layer.raw_uncertainty is not None:
            plot_error_item = pg.ErrorBarItem(
                x=plot_container.layer.masked_dispersion.compressed().value,
                y=plot_container.layer.masked_data.compressed().value,
                height=plot_container.layer.raw_uncertainty.compressed().value,
            )
            plot_container.error = plot_error_item

        if plot_container.layer.mask is not None:
            mask = plot_container.layer.mask
            x = plot_container.layer.masked_dispersion.data.value[mask]
            y = plot_container.layer.masked_data.data.value[mask]
            plot_mask_item = pg.ScatterPlotItem(
                x=x,
                y=y,
                symbol='x'
            )
            plot_container.mask = plot_mask_item

        return plot_container
github biolab / orange3-prototypes / orangecontrib / prototypes / widgets / owpolynomialregression.py View on Github external
def plot_scatter_points(self, x_data, y_data):
        if self.scatterplot_item:
            self.plotview.removeItem(self.scatterplot_item)
        self.n_points = len(x_data)
        self.scatterplot_item = pg.ScatterPlotItem(
            x=x_data, y=y_data, data=np.arange(self.n_points),
            symbol="o", size=10, pen=pg.mkPen(0.2), brush=pg.mkBrush(0.7),
            antialias=True)
        self.scatterplot_item.opts["useCache"] = False
        self.plotview.addItem(self.scatterplot_item)
        self.plotview.replot()
github vasole / pymca / PyMca5 / PyMcaGraph / backends / PyQtGraphBackend.py View on Github external
QtCore.Qt.OpenHandCursor,
                                QtCore.Qt.SizeAllCursor]:
                self._originalCursorShape = oldShape
                self.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        else:
            if self._originalCursorShape in [QtCore.Qt.SizeHorCursor,
                                QtCore.Qt.SizeVerCursor,
                                QtCore.Qt.PointingHandCursor,
                                QtCore.Qt.OpenHandCursor,
                                QtCore.Qt.SizeAllCursor]:
                #arrow as default
                self.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
            else:
                self.setCursor(QtGui.QCursor(self._originalCursorShape))

class ScatterPlotItem(pg.ScatterPlotItem):
    def mouseClickEvent(self, ev):
        if ev.button() == QtCore.Qt.MiddleButton:
            ev.ignore()
            return
        if ev.button() == QtCore.Qt.RightButton:
            button = "right"
        else:
            button = "left"
        if ev.button() == QtCore.Qt.LeftButton:
            pts = self.pointsAt(ev.pos())
            if len(pts) > 0:
                self.ptsClicked = pts
                ev.accept()
                ddict = {}
                if ev.double():
                    ddict["event"] = "curveDoubleClicked"
github BioDepot / BioDepot-workflow-builder / orange3 / Orange / widgets / evaluate / owrocanalysis.py View on Github external
def extend_to_origin(points):
        "Extend ROCPoints to include coordinate origin if not already present"
        if points.tpr.size and (points.tpr[0] > 0 or points.fpr[0] > 0):
            points = ROCPoints(
                numpy.r_[0, points.fpr],
                numpy.r_[0, points.tpr],
                numpy.r_[points.thresholds[0] + 1, points.thresholds],
            )
        return points

    points = extend_to_origin(curve.points)
    item = pg.PlotCurveItem(
        points.fpr, points.tpr, pen=pen, shadowPen=shadow_pen, name=name, antialias=True
    )
    sp = pg.ScatterPlotItem(
        curve.points.fpr,
        curve.points.tpr,
        symbol=symbol,
        size=symbol_size,
        pen=shadow_pen,
        name=name,
    )
    sp.setParentItem(item)

    hull = extend_to_origin(curve.hull)

    hull_item = pg.PlotDataItem(hull.fpr, hull.tpr, pen=pen, antialias=True)
    return PlotCurve(curve, item, hull_item)