Restarting/resetting a graph, preparing for new measurements/data

39 views
Skip to first unread message

Hamza kadhum

unread,
May 10, 2018, 1:56:15 PM5/10/18
to pyqtgraph

Hello! 
I have made a graph that plots sensor signals, and i have it in a class such Qt4 GUI can show it in widget. I have tried few things lately but it haven't fulfilled my wishes. 
I want my graph to reset/reload or whatever you want to call it when i want to start new measurements, that is graph with no data plotted. 
I've been trying repaint, update etc but can't quite get it to work, matter fact i dont understand if i am using repaint/update correctly.

Any suggestions how i may solve this issue? 

Best Regards, 

Hamza 

Patrick

unread,
May 10, 2018, 10:08:40 PM5/10/18
to pyqtgraph
Hi Hamza,

It's missing from the documentation of PlotDataItem (http://www.pyqtgraph.org/documentation/_modules/pyqtgraph/graphicsItems/PlotDataItem.html) but there is a clear() method, which should do what you want. Alternatively, you could probably setData(0).

(I find looking at the source code found behind the green "[source]" link in the documentation can reveal a few useful undocumented features).

Patrick

Hamza kadhum

unread,
May 11, 2018, 2:39:49 AM5/11/18
to pyqt...@googlegroups.com
Hello! Thank you for your respond! 

I started with doing that method but it didn't work as when i called clear(), it removed the data from the graph as it supposed to but when i started to plot again, calling another function, it started where it stopped and showed previous plots. 
It feels like it never actually empty the setData or DataItem. 

example: 
win = pg.GraphicsWindow(...)
p1 = win.addPlot(...)
curve1= p1.plot() 
curve2=p1.plot()

def somefunction():
       if x=something:
           curve1.clear()
           curve2.clear() 
def replot():
      plot new data 
     curve1.setData(x)
     curve2.setData(y)

My point is, at function "replot" it plots old values and start where "somefunction" was called, where clear() was called. Does it work for you when you call clear?


--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/00b270c5-b395-466d-891b-ba87a3c77d06%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

HK

unread,
May 11, 2018, 3:03:38 AM5/11/18
to pyqtgraph
Hello!

I just solved it, the issue was in the append syntax which i thought I set it to 0. Clear works perfectly but everytime it trys to replot, it uses ys.append(data) so the solution is to clear append too. ys.clear(). will solve the issue. 
Reply all
Reply to author
Forward
0 new messages