How to clear a ScatterPlotItem

84 views
Skip to first unread message

MudloggerMike

unread,
Oct 5, 2016, 6:44:07 PM10/5/16
to pyqtgraph

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'.

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

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

dani

unread,
Dec 3, 2016, 1:25:57 PM12/3/16
to pyqtgraph
Hello dear, I hope I solved the problem. 
What you say is that the cursor path is plotted? This is what I want to do.
I am using a code to get the coordinates of the cursor, but I can not return the values outside the function, since I want to save them in .csv

I hope someone can help me return the values outside the function.
Thank you very much for your attention.

Code is:

import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore

Point = []
def mouseMoved(evt):
global Point, cursor2
mousePoint = p.vb.mapSceneToView(evt[0])
Point.append([mousePoint.x(), mousePoint.y()])
#print Point
#print mousePoint.x(), mousePoint.y()

win = pg.GraphicsWindow()
win.resize(700, 600)

p = win.addPlot()
p.setMouseEnabled(x=False, y=False)
p.setXRange(-60, 60, padding=None)
p.setYRange(140, 250, padding=None)
p.showGrid(x=True, y=True, alpha=0.3)

proxy = pg.SignalProxy(p.scene().sigMouseMoved, rateLimit=60, slot=mouseMoved)

if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()


Best regards!!
Daniel Araya Rocha
Reply all
Reply to author
Forward
0 new messages