I am using the development version 0.9.11 with  pyQT5 on a windows machine.

I've created a descendant of PlotWidget that catches a pypubsub message 
that is used to update the plot in the plotwidget.

The code for doing this is posted below.  I seems to work OK, except for 
the fact that  the plot stops refreshing itself after the initial number of 
samples is reached.

However, if I manually adjust the window size by using a mouse to drag the 
edge of the window then the refresh does occur as I am doing the dragging.  
If I stop adjusting the window size then the plot does not update.

Any suggestions as to how I can make the plot continuously update without 
manual intervention.


from __future__ import unicode_literals
import numpy as np
from pubsub import pub
import pyqtgraph_dev as pg

class ScatterPlotCanvas(pg.PlotWidget):

    def __init__(self):
        self.xdata = [0]  
        self.ydata = [0]   

        self.curve = self.plot(pen='r')
        self.samples = 100

    def updateXY(self,  xval, yval, samples):

        if len(self.xdata) == 1:
            self.xdata = [xval, xval]  
            self.ydata = [yval, yval]   
            if len(self.xdata) > samples:
               frm = len(self.xdata)-samples
               self.xdata = self.xdata[frm:]
               self.ydata = self.ydata[frm:]

            self.xdata = np.append(self.xdata,xval)    
            self.ydata = np.append(self.ydata,yval)  

        self.curve.setData(x=self.xdata, y=self.ydata)

    def receiveData(self, arg1=None, arg2=None):
        if arg1 is not None:
           xval = arg2[0,:]
           yval = arg2[1,:]
           for x,y in zip(xval, yval):
              self.updateXY(x, y, self.samples)


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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to