Multiple plots blocks the window

37 views
Skip to first unread message

Diego Fernando

unread,
Dec 15, 2019, 12:01:15 PM12/15/19
to pyqtgraph

Hi guys,

I'm trying to plot in real time several data in different plots. At firts it works great but after some time the window blocks but keeps plotting the data.

I'm getting the data from a thread. and the code I'm using to plot looks like this:

        self.pg_plot_one.plot(
           range(self.n)[d:],
           self.y1[d:],
           pen=(1, 3),
           antialias=True,
           name="x axis"
       )
        self.pg_plot_one.plot(
           range(self.n)[d:],
           self.y2[d:],
           pen=(2, 3),
           antialias=True,
           name="y axis"
       )


Any suggestions?

Thanks

vas...@gmail.com

unread,
Dec 15, 2019, 12:18:51 PM12/15/19
to pyqt...@googlegroups.com
Hi Diego,

With pg.plot (http://www.pyqtgraph.org/documentation/functions.html#pyqtgraph.plot) you create a new PlotWindow every time you start this function, but you need to create them just one time and then fill with setData (http://www.pyqtgraph.org/documentation/graphicsItems/plotcurveitem.html#pyqtgraph.PlotCurveItem.setData) function. So, you are overloading (probably) ViewBox with lots of a new plots.


You should do something like this:
// initalize the PlotWindows
self.pg_plot_one_1 = self.pg_plot_one.plot() 
self.pg_plot_one_2 self.pg_plot_one.plot()   

then in a loop:
    self.pg_plot_one.setRange(xRange=range(self.n)[d:]) // maybe this line not need in a loop. look at http://www.pyqtgraph.org/documentation/graphicsItems/viewbox.html#pyqtgraph.ViewBox.setRange
self.pg_plot_one_1.setData(self.y1[d:], pen=(1, 3), antialias=True)
self.pg_plot_one_2.setData(self.y2[d:], pen=(2, 3), antialias=True)  

Of course, it is the best that you make combination you need.

Good luck,
Vasilije

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/ab3365fa-e10e-4d3f-8561-2788c81707fc%40googlegroups.com.

Diego Fernando

unread,
Dec 15, 2019, 1:15:06 PM12/15/19
to pyqtgraph
Thank you so much. That was it.
Reply all
Reply to author
Forward
0 new messages