How do I clear a ScatterPlotItem in PYQTGRAPH
<p>I am attempting to move a "cursor" around my graph using ScatterPlotItem and a '+' symbol as the cursor. The cursor updates its position perfectly but I cannot figure out how to clear the last instance. Here is the line that I use to plot the 'cursor'.</p>

<pre><code>self.cursor2 = self.p2_3.addItem(pg.ScatterPlotItem([self.xx], [self.yy], pen=None, symbol='+', color = 'b'))
</code></pre>

<p>I tried self.cursor2.clear() but that didn't work. Any help is appreciated. </p>

<p>When you call addItem you add the plotdataitem, in this case a scatterplotitem to your plotitem. To remove it you call removeItem in the same way. But you need to keep a reference to the scatterplotitem to do that.</p>

<p>Note that addItem doesn't return anything i.e. your self.cursor2 is None.</p>

<p>If you want to remove everything from your plot you could call</p>

<pre><code>self.p2_3.clear()
</code></pre>

<p>otherwise to just remove the scatterplotitem you can do like this</p>

<pre><code>import pyqtgraph as pg

win = pg.GraphicsWindow()
plotitem = win.addPlot()
scatterplot = pg.ScatterPlotItem([2], [3], symbol='+', color = 'b')

plotitem.addItem(scatterplot)
plotitem.removeItem(scatterplot)
</code></pre>

python python-2.7 pyqtgraph