Real Time Signal Plotting

7,193 views
Skip to first unread message

Federico Bolaños

unread,
Jun 29, 2014, 2:43:40 PM6/29/14
to pyqt...@googlegroups.com

Hello everyone!

I am wondering if it's possible to develop a script that uses pyqtgraph and mimics the performance of this script:

If so, could anyone point me to an example that does this? or help me write part of the code?

The reason I don't want to use that particular script is because I think pyqtgraph will offer much more flexibility, I can resize the plot, perhaps have another plot that does an FFT of the signal, or even do real time signal processing which may be harder to implement on that example script.

In short, I want to be able to plot the signal coming from an ADC as fast as I can. I wrote a class that allows me to interface with said ADC and I would like to obtain the data as fast as I can and at the same time plot the data a correct time x axis. The ADC class that I wrote returns an integer each time it is polled, sort of like if I were to do random.randint(0, 1024).

I have been looking for an example that uses this library since it is very lightweight and runs nicely on a raspberry pi! (So does the above script, but I would really like the flexibility that pyqtgraph provides)


Thanks for reading,
Federico

Luke Campagnola

unread,
Jun 29, 2014, 3:46:10 PM6/29/14
to pyqt...@googlegroups.com
On Sun, Jun 29, 2014 at 2:43 PM, Federico Bolaños <casca...@gmail.com> wrote:

Hello everyone!

I am wondering if it's possible to develop a script that uses pyqtgraph and mimics the performance of this script:

Here's a simple example:

import pyqtgraph as pg
import numpy as np
plt = pg.plot()
bufferSize = 1000
data = np.zeros(bufferSize)
curve = plt.plot()
line = plt.addLine(x=0)
plt.setRange(xRange=[0, bufferSize], yRange=[-50, 50])
i = 0
def update():
    global data, curve, line, i
    n = 10  # update 10 samples per iteration
    rand = np.random.normal(size=n)
    data[i:i+n] = np.clip(data[i-1] + rand, -50, 50)
    curve.setData(data)
    i = (i+n) % bufferSize
    line.setValue(i)

timer = pg.QtCore.QTimer()
timer.timeout.connect(update)
timer.start(20)


To improve the performance of this example, you would just need to update more samples in the data array at each iteration.
You might also have a look at the scrolling plot examples:
https://github.com/pyqtgraph/pyqtgraph/blob/develop/examples/scrollingPlots.py

Federico Bolaños

unread,
Jun 29, 2014, 5:02:11 PM6/29/14
to pyqt...@googlegroups.com
The perils of having an outdated library. I didn't realize that there were specific examples for this. My apologies!

I have one other question, do you think it would be best if I made a class that runs as a separate thread which obtains the values of the ADC and then when I poll it from the pyqtgraph script I make it return an array of the latest non read values? 
Or should I just make the pyqtgraph read the ADC value by value with each loop of the script??

Thanks for the ridiculously fast reply.

Luke Campagnola

unread,
Jun 29, 2014, 8:23:46 PM6/29/14
to pyqt...@googlegroups.com
On Sun, Jun 29, 2014 at 5:02 PM, Federico Bolaños <casca...@gmail.com> wrote:
The perils of having an outdated library. I didn't realize that there were specific examples for this. My apologies!

My fault for not having released it yet :)
 
I have one other question, do you think it would be best if I made a class that runs as a separate thread which obtains the values of the ADC and then when I poll it from the pyqtgraph script I make it return an array of the latest non read values? 
Or should I just make the pyqtgraph read the ADC value by value with each loop of the script??

Although I recommend to avoid threading whenever possible, there are some situations when it is helpful:
1) Plotting takes too much time, causing the acquisition to drop data.
2) Reading data takes too much time, causing the GUI to become unresponsive.
If you have neither of these situations, then running both acquisition and plotting from the event loop should be just fine.

Federico Bolaños

unread,
Jun 29, 2014, 11:13:45 PM6/29/14
to pyqt...@googlegroups.com


On Sunday, June 29, 2014 5:23:46 PM UTC-7, Luke Campagnola wrote:

Although I recommend to avoid threading whenever possible, there are some situations when it is helpful:
1) Plotting takes too much time, causing the acquisition to drop data.
2) Reading data takes too much time, causing the GUI to become unresponsive.
If you have neither of these situations, then running both acquisition and plotting from the event loop should be just fine.

Well I plan on graphing (and hopefully analysing) real time EEG data. Currently I am working with random noise because I am waiting on the parts to build the amplifier.
Modern literature says that sampling the ADC at 400-600Hz would be adequate. I wonder if I can graph at half of that so about 200-300Hz? 

Each time I sample the ADC I obtain a particular voltage from 0 to 5V represented as a 12 Bit integer. Given that information, what do you think would be the best way to implement the data acquisition?
Also, many thanks for your above example (the quick one you wrote), I am also trying to add an adequate time axis for each point that is graphed, which is another obstacle I am facing. I am wondering whether each point I sample from the ADC should be timestamped from a time.time() baseline, and then when I graph the data I take the Y value (voltage) and the X value (time.time()) from a list.

Federico Bolaños

unread,
Jun 30, 2014, 1:39:01 AM6/30/14
to pyqt...@googlegroups.com
Actually I got somewhere:
import pyqtgraph as pg
import numpy as np
from pyqtgraph.Qt import QtCore, QtGui
import random


app = QtGui.QApplication([])


plt = pg.plot()
bufferSize = 2000
maxTime = 3
data = np.zeros((bufferSize, 2))

curve = plt.plot()
line = plt.addLine(x=0)
plt.setRange(xRange=[0, maxTime], yRange=[-50, 50])
i = 0
lasti = 0
n_times = 0 
t_start = pg.ptime.time()

def update():
    global data, curve, line, i, t_start, lasti, n_times
    n = 1  # update 10 samples per iteration
    rand = random.randint(-1,1)
    #print rand
    dt = pg.ptime.time()-t_start
    data[i+n, 0] = np.clip(data[i, 0] + rand, -50, 50)
    data[i+n, 1] = dt
    i = i+n
    n_times += 1
    #print i
    if dt >= 3:
        t_start = pg.ptime.time()
        print n_times
        n_times = 0
        data[i]
        i = 0
    line.setValue(dt)
    curve.setData(data[:,1],data[:,0])

        
timer = pg.QtCore.QTimer()
timer.timeout.connect(update)
timer.start(0) #Hopefully makes it run as fast as possible.


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

Problem is... that sometimes it samples more times in one run and thus there are left over points from the last sweep. Also, the fact that I have to initialize the numpy array with 2000 zeroes and that causes a line to show up joining the point (0, 0) with the latest point...

Any ideas on how to fix it?

Luke Campagnola

unread,
Jun 30, 2014, 6:41:20 AM6/30/14
to pyqt...@googlegroups.com
On Sun, Jun 29, 2014 at 11:13 PM, Federico Bolaños <casca...@gmail.com> wrote:


On Sunday, June 29, 2014 5:23:46 PM UTC-7, Luke Campagnola wrote:

Although I recommend to avoid threading whenever possible, there are some situations when it is helpful:
1) Plotting takes too much time, causing the acquisition to drop data.
2) Reading data takes too much time, causing the GUI to become unresponsive.
If you have neither of these situations, then running both acquisition and plotting from the event loop should be just fine.

Well I plan on graphing (and hopefully analysing) real time EEG data. Currently I am working with random noise because I am waiting on the parts to build the amplifier.
Modern literature says that sampling the ADC at 400-600Hz would be adequate. I wonder if I can graph at half of that so about 200-300Hz? 

Your screen probably updates at 60Hz, and Qt is pretty good about limiting its updates to that frame rate. You can still plot data that is sampled faster, but it won't be useful to try plotting at a higher frame rate.
 

Each time I sample the ADC I obtain a particular voltage from 0 to 5V represented as a 12 Bit integer. Given that information, what do you think would be the best way to implement the data acquisition?

If you acquire one sample every time the computer requests the ADC value, then you will very likely want to run a second thread for acquisition. Otherwise, you will have large gaps in the data every time the plot is updated. Even with multiple threads, your data will be sampled irregularly which can make analysis difficult (for example, the fourier transform might not be trivial to compute). Even with a thread dedicated to acquisition, you might still have large gaps in the data due to other processes in the system blocking CPU access. A solution to most of these problems is have the acquisition hardware time its own readings, but that complicates the hardware implementation. What kind of ADC hardware do you have?

Luke Campagnola

unread,
Jun 30, 2014, 6:42:58 AM6/30/14
to pyqt...@googlegroups.com
On Mon, Jun 30, 2014 at 1:39 AM, Federico Bolaños <casca...@gmail.com> wrote:
Problem is... that sometimes it samples more times in one run and thus there are left over points from the last sweep. Also, the fact that I have to initialize the numpy array with 2000 zeroes and that causes a line to show up joining the point (0, 0) with the latest point...

You just need to keep track of which samples in the buffer are valid and avoid plotting invalid samples.

Lisandro Raviola

unread,
Jun 30, 2014, 10:47:55 AM6/30/14
to pyqt...@googlegroups.com
Hello Luke and Federico,

I have one other question, do you think it would be best if I made a class that runs as a separate thread which obtains the values of the ADC and then when I poll it from the pyqtgraph script I make it return an array of the latest non read values? 
Or should I just make the pyqtgraph read the ADC value by value with each loop of the script??

Although I recommend to avoid threading whenever possible, there are some situations when it is helpful:
1) Plotting takes too much time, causing the acquisition to drop data.
2) Reading data takes too much time, causing the GUI to become unresponsive.
If you have neither of these situations, then running both acquisition and plotting from the event loop should be just fine.
 
Luke, what's the rationale behind avoiding threading?

I'm working on a project in which I need to plot voltage values coming from the serial port in real time. The data come from a microcontroller-based data acquisition device. Currently I'm doing this using two timers: one of them is connected to a function (sample_read) which polls the serial port at a user-defined frequency and stores the incoming value and a timestamp in a list; the other one calls a function (update_plot) responsible for updating the plot whenever there is new data to be displayed.

This approach has some drawbacks, first of all the overhead of calling the serial port polling function when the frequency needed is high enough (for example, hundred of times per second), and second, the fact that the timestamp is generated by the computer with (at best) millisecond resolution, but that is not guaranteed. Also, I noticed that the QTimer is not able to work reliably at high frequencies (200 Hz or more).

I can manage to program the data acquisition device for sending data continuously while sampling at a fixed frequency (even as high as 10 KHz), so I was thinking in running the serial port listening function as a separate thread instead of using a timer. In this way, the incoming data get read quickly and I get an accurate timestamp for each sample. Do you think there is a better strategy for doing this without threading?

Sorry if my question is not directly related to pyqtgraph, but probably the next ones will be more on-topic as my project progresses.
Last but not least, thank you so much for putting such a big effort in building and supporting this library and for sharing it with the rest of us.

Regards,
Lisandro.


Luke Campagnola

unread,
Jun 30, 2014, 11:14:01 AM6/30/14
to pyqt...@googlegroups.com
On Mon, Jun 30, 2014 at 10:47 AM, Lisandro Raviola <rav...@gmail.com> wrote:
Hello Luke and Federico,

I have one other question, do you think it would be best if I made a class that runs as a separate thread which obtains the values of the ADC and then when I poll it from the pyqtgraph script I make it return an array of the latest non read values? 
Or should I just make the pyqtgraph read the ADC value by value with each loop of the script??

Although I recommend to avoid threading whenever possible, there are some situations when it is helpful:
1) Plotting takes too much time, causing the acquisition to drop data.
2) Reading data takes too much time, causing the GUI to become unresponsive.
If you have neither of these situations, then running both acquisition and plotting from the event loop should be just fine.
 
Luke, what's the rationale behind avoiding threading?

* It is easy to implement threading incorrectly, and the consequence is usually random crashing that is very difficult to debug
* the python global interpreter lock actually prevents the python interpreter from running in more than one thread at a time, so depending on the details of your application, you may or may not get any performance benefit. There are many articles on this topic, but the short story is that at least one of your threads must be either idle (perhaps waiting for serial data) or executing a function that does not return to the interpreter for a long time (for example, an expensive number-crunching function that releases the GIL before it starts).
 
 
I'm working on a project in which I need to plot voltage values coming from the serial port in real time. The data come from a microcontroller-based data acquisition device. Currently I'm doing this using two timers: one of them is connected to a function (sample_read) which polls the serial port at a user-defined frequency and stores the incoming value and a timestamp in a list; the other one calls a function (update_plot) responsible for updating the plot whenever there is new data to be displayed.

This approach has some drawbacks, first of all the overhead of calling the serial port polling function when the frequency needed is high enough (for example, hundred of times per second), and second, the fact that the timestamp is generated by the computer with (at best) millisecond resolution, but that is not guaranteed. Also, I noticed that the QTimer is not able to work reliably at high frequencies (200 Hz or more).

If you need precise timing at high frequency, it is almost mandatory that your acquisition hardware handle the timing--the CPU is too busy doing other things to be reliable for this purpose. You might be able to improve timing by increasing the priority of the acquisition thread, but this will likely make the GUI unresponsive.


I can manage to program the data acquisition device for sending data continuously while sampling at a fixed frequency (even as high as 10 KHz), so I was thinking in running the serial port listening function as a separate thread instead of using a timer. In this way, the incoming data get read quickly and I get an accurate timestamp for each sample. Do you think there is a better strategy for doing this without threading?

This sounds good, and also sounds like you would not need threading at all. The important question is: how long can you allow data to accumulate in the serial port buffer before it drops data? If the buffer is large enough, then you could read serial data only once for each plot update. You might not even need two different timers. If the buffer is small, however, then you might very well need a separate thread to increase the frequency of reads to the serial port.

Other references:

Example of multi-threading with pyqtgraph:
https://groups.google.com/d/msg/pyqtgraph/haiJsGhxTaQ/sTtMa195dHsJ

Long ago I posted some pyqtgraph code for acquiring 1Ms/s data from an Arduino Due:
http://forum.arduino.cc/index.php?topic=137635.15;wap2

Lisandro Raviola

unread,
Jul 1, 2014, 3:03:12 PM7/1/14
to pyqt...@googlegroups.com
Luke, thanks for the explanation. I will check the references.

Regards,
Lisandro.

Jannis Mainczyk

unread,
Feb 1, 2018, 4:47:26 AM2/1/18
to pyqtgraph
Hello everyone,

I stumbled across this old thread while trying to solve the problem of plotting a time series with missing/invalid data with pyqtgraph.

My current solution involves invalid data indicators and creation of a new CurveItem for each bit of consecutive valid data, but the implementation is rather complex.

@Luke Is there a way within pyqtgraph to plot one single CurveItem with missing data (e.g. np.nan values) and have the curve _not_ connect the two valid points, like described by Frederico?

mallamma Reddy

unread,
Jun 29, 2019, 8:00:06 AM6/29/19
to pyqtgraph
    I am trying to plot some random data using `pyqtgraph`. I used the "scrolling graph" example from "`pyqtgraph.examples`" as template to create a plot for my data.
        
    I have defined two functions here one for button event and other for update data. 
    I want to plot the data when the checkbox and plot button is clicked. 
    I found many more  examples like this "Updating and PlotWidgets in PyQt4 for Live Plotting" but din't get idea how to use it for  `pg.PlotWidget()`.
    The below code I found in "`pyqtgraph.examples`" and here they used `GraphicsWindow()`.
                    
            def update():
                global data, curve, ptr
                data[:-1] = data[1:]  
                data[-1] = np.random.normal()
                curve.setData(data)
                ptr += 1    
                curve.setData(data)
                curve.setPos(ptr, 0)
            timer = pg.QtCore.QTimer()
            timer.timeout.connect(update)
            timer.start(50) 
                    
    But in my code i am using `self.graphicsView = pg.PlotWidget(self.centralwidget)`. Here the graph is static and its not rolling.So here i want to update the data but here data is not updating and plot is not moving .
Can anyone help how can i update the data an how to use `plotWidget` and `QTimer`?
                    
    class Ui_MainWindow(QtGui.QWidget):
        def __init__(self, parent=None):
            super(Ui_MainWindow, self).__init__(parent)
            # Desired Frequency (Hz) = 1 / self.FREQUENCY
            # USE FOR TIME.SLEEP (s)
            self.FREQUENCY = .004
    
            # Frequency to update plot (ms)
            # USE FOR TIMER.TIMER (ms)
            self.TIMER_FREQUENCY = self.FREQUENCY * 1000
    
            # Set X Axis range. If desired is [-10,0] then set LEFT_X = -10 and RIGHT_X = 0
            self.LEFT_X = 0
            self.RIGHT_X = 3
            self.X_Axis = np.arange(self.LEFT_X, self.RIGHT_X, self.FREQUENCY)
            self.buffer = int((abs(self.LEFT_X) + abs(self.RIGHT_X))/self.FREQUENCY)
            self.data = [] 
            self.graphicsView = pg.PlotWidget(self.centralwidget)
         ##   self.graphicsView = pg.PlotWidget()
      
            self.graphicsView.plotItem.setMouseEnabled(x=False, y=False)
            self.graphicsView.setXRange(self.LEFT_X, self.RIGHT_X)
            self.graphicsView.setTitle('Scrolling Plot Example')
            self.graphicsView.setLabel('left', 'Value')
            self.graphicsView.setLabel('bottom', 'Time (s)')
    
            self.scrolling_plot = self.graphicsView.plot()
    ##        self.scrolling_plot.setPen(197,235,255)
          
            self.layout = QtGui.QGridLayout()
            self.layout.addWidget(self.graphicsView)
    
            self.read_position_thread()
            self.start()
    
        def start(self):
            self.position_update_timer = QtCore.QTimer()
            self.position_update_timer.timeout.connect(self.Plot_Button)
            self.position_update_timer.start(self.get_scrolling_plot_timer_frequency())
    
        def read_position_thread(self):
            self.current_position_value = 0
            self.old_current_position_value = 0
            self.position_update_thread = Thread(target=self.read_position, args=())
            self.position_update_thread.daemon = True
            self.position_update_thread.start()
    
        def read_position(self):
            frequency = self.get_scrolling_plot_frequency()
            while True:
                try:
                    self.current_position_value = random.randint(1,101)
                    self.old_current_position_value = self.current_position_value
                    time.sleep(frequency)
                except:
                    self.current_position_value = self.old_current_position_value
    
        def Plot_Button(self):
            if self.Sensor1.isChecked():
                self.dataPoint = float(self.current_position_value)
                if len(self.data) >= self.buffer:
                    del self.data[:1]
                self.data.append(self.dataPoint)
                self.scrolling_plot.setData(self.X_Axis[len(self.X_Axis) - len(self.data):], self.data)
        def clear_scrolling_plot(self):
            self.data[:] = []
    
        def get_scrolling_plot_frequency(self):
            return self.FREQUENCY
    
        def get_scrolling_plot_timer_frequency(self):
            return self.TIMER_FREQUENCY
    
        def get_scrolling_plot_layout(self):
            return self.layout
    
        def get_current_position_value(self):
            return self.current_position_value
    
        def get_scrolling_plot_widget(self):
            return self.graphicsView
               
        def Pause_Button(self):
            QCoreApplication.instance().quit()
            print("fail")
        def setupUi(self, MainWindow):
            MainWindow.setObjectName("MainWindow")
            MainWindow.resize(795, 359)             
            self.centralwidget = QtWidgets.QWidget(MainWindow)
            self.centralwidget.setObjectName("centralwidget")      
            self.Plot = QtWidgets.QPushButton(self.centralwidget)
            self.Plot.setGeometry(QtCore.QRect(530, 260, 80, 23))
            self.Plot.setObjectName("Plot")
            self.Plot.clicked.connect(self.Plot_Button)
            self.Pause = QtWidgets.QPushButton(self.centralwidget)
            self.Pause.setGeometry(QtCore.QRect(620, 260, 80, 23))
            self.Pause.setObjectName("Pause")#
            self.Pause.clicked.connect(self.Pause_Button)            
            self.frame = QtWidgets.QFrame(self.centralwidget)
            self.frame.setGeometry(QtCore.QRect(520, 10, 251, 291))
            self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
            self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
            self.frame.setObjectName("frame")       
            self.label = QtWidgets.QLabel(self.frame)
            self.label.setGeometry(QtCore.QRect(140, 6, 101, 20))
    ##      self.label.setObjectName("Sampling Frequency")
            self.label.setObjectName("label")
            self.label_2 = QtWidgets.QLabel(self.frame)
            self.label_2.setGeometry(QtCore.QRect(150, 40, 51, 20))
    ##        self.label_2.setObjectName("Offset")
            self.label_2.setObjectName("label_2")
            self.Sensor1 = QtWidgets.QCheckBox(self.frame)
            self.Sensor1.setGeometry(QtCore.QRect(30, 70, 74, 21))
            self.Sensor1.setObjectName("Sensor1")  
            self.Sensor2 = QtWidgets.QCheckBox(self.frame)
            self.Sensor2.setGeometry(QtCore.QRect(30, 90, 74, 21))
            self.Sensor2.setObjectName("Sensor2")     
            self.Sensor3 = QtWidgets.QCheckBox(self.frame)
            self.Sensor3.setGeometry(QtCore.QRect(30, 110, 74, 21))
            self.Sensor3.setObjectName("Sensor3")        
            self.Sensor4 = QtWidgets.QCheckBox(self.frame)
            self.Sensor4.setGeometry(QtCore.QRect(30, 130, 71, 21))
            self.Sensor4.setObjectName("Sensor4")
            self.Sensor5 = QtWidgets.QCheckBox(self.frame)
            self.Sensor5.setGeometry(QtCore.QRect(30, 150, 74, 21))
            self.Sensor5.setObjectName("Sensor5")    
            self.Sensor6 = QtWidgets.QCheckBox(self.frame)
            self.Sensor6.setGeometry(QtCore.QRect(30, 170, 74, 21))
            self.Sensor6.setObjectName("Sensor6")
            self.Sensor7 = QtWidgets.QCheckBox(self.frame)
            self.Sensor7.setGeometry(QtCore.QRect(30, 190, 74, 21))
            self.Sensor7.setObjectName("Sensor7")     
            self.Sensor8 = QtWidgets.QCheckBox(self.frame)
            self.Sensor8.setGeometry(QtCore.QRect(30, 210, 71, 21))
            self.Sensor8.setObjectName("Sensor8")
            self.lineEdit_1 = QtWidgets.QLineEdit(self.frame)
            self.lineEdit_1.setGeometry(QtCore.QRect(20, 10, 113, 21))
            self.lineEdit_1.setObjectName("lineEdit_1")        
            self.lineEdit_2 = QtWidgets.QLineEdit(self.frame)
            self.lineEdit_2.setGeometry(QtCore.QRect(20, 40, 113, 20))
            self.lineEdit_2.setObjectName("lineEdit_2")       
    ##        self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget)
            self.graphicsView = pg.PlotWidget(self.centralwidget)
    ##        self.graphicsView.setXRange(self.LEFT_X, self.RIGHT_X)
            self.graphicsView.setLabel('bottom', 'Time (s)')
            self.graphicsView.setLabel('left', 'Value')
            self.graphicsView.setGeometry(QtCore.QRect(5, 11, 501, 291))
            self.graphicsView.setObjectName("graphicsView")       
            self.frame.raise_()
            self.Plot.raise_()
            self.Pause.raise_()
            self.graphicsView.raise_()
            MainWindow.setCentralWidget(self.centralwidget)
            self.menubar = QtWidgets.QMenuBar(MainWindow)
            self.menubar.setGeometry(QtCore.QRect(0, 0, 795, 21))      
            self.menubar.setObjectName("menubar")
            self.menuFile = QtWidgets.QMenu(self.menubar)        
            self.menuFile.setObjectName("menuFile")
            self.menuAbout = QtWidgets.QMenu(self.menubar)  
            self.menuAbout.setObjectName("menuAbout")
            MainWindow.setMenuBar(self.menubar)       
            self.statusbar = QtWidgets.QStatusBar(MainWindow)
            self.statusbar.setObjectName("statusbar")
            MainWindow.setStatusBar(self.statusbar)
            self.actionOpen = QtWidgets.QAction(MainWindow)
            self.actionOpen.setObjectName("actionOpen")       
            self.actionSave_As = QtWidgets.QAction(MainWindow)
            self.actionSave_As.setObjectName("actionSave_As")        
            self.actionScreenshot = QtWidgets.QAction(MainWindow)
            self.actionScreenshot.setObjectName("actionScreenshot")        
            self.actionExit = QtWidgets.QAction(MainWindow)
            self.actionExit.setObjectName("actionExit")        
            self.menuFile.addAction(self.actionOpen)
            self.menuFile.addAction(self.actionSave_As)
            self.menuFile.addAction(self.actionScreenshot)
            self.menuFile.addAction(self.actionExit)
            self.menubar.addAction(self.menuFile.menuAction())
            self.menubar.addAction(self.menuAbout.menuAction())
            self.retranslateUi(MainWindow)
            QtCore.QMetaObject.connectSlotsByName(MainWindow)
            
        def retranslateUi(self, MainWindow):
            _translate = QtCore.QCoreApplication.translate
            MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
            self.Plot.setText(_translate("MainWindow", "Plot"))
            self.Pause.setText(_translate("MainWindow", "Pause"))
            self.label.setText(_translate("MainWindow", "Sampling Frequency"))
            self.label_2.setText(_translate("MainWindow", "Offset"))
            self.Sensor1.setText(_translate("MainWindow", "Sensor1"))
            self.Sensor2.setText(_translate("MainWindow", "Sensor2"))
            self.Sensor3.setText(_translate("MainWindow", "Sensor3"))
            self.Sensor4.setText(_translate("MainWindow", "Sensor4"))
            self.Sensor5.setText(_translate("MainWindow", "Sensor5"))
            self.Sensor6.setText(_translate("MainWindow", "Sensor6"))
            self.Sensor7.setText(_translate("MainWindow", "Sensor7"))
            self.Sensor8.setText(_translate("MainWindow", "Sensor8"))
            self.menuFile.setTitle(_translate("MainWindow", "File"))
            self.menuAbout.setTitle(_translate("MainWindow", "About"))
            self.actionOpen.setText(_translate("MainWindow", "Open"))
            self.actionSave_As.setText(_translate("MainWindow", "Save As"))
            self.actionScreenshot.setText(_translate("MainWindow", "Screenshot"))
            self.actionExit.setText(_translate("MainWindow", "Exit"))
            
    
    if __name__ == "__main__":
        import sys
        app = QtWidgets.QApplication(sys.argv)
        MainWindow = QtWidgets.QMainWindow()
        ui = Ui_MainWindow()
        ui.setupUi(MainWindow)
        MainWindow.show()
        sys.exit(app.exec_())
        if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
            QtGui.QApplication.instance().exec_()
    
    Now I made changes in my code. Values are updating but I am not able to see the graph on widget since I am using `self.graphicsView = pg.PlotWidget(self.centralwidget)` inside the  function .
    In the above example they using `self.scrolling_plot_widget = pg.PlotWidget()`. 
How do I change it for plotting in `pg.PlotWidget(self.centralwidget)`. where I am missing the code and where and in which funcion i need to call the PlotWidget()????.

mallamma

unread,
Jun 29, 2019, 8:10:04 AM6/29/19
to pyqtgraph
Can anyone help me to solve the problem which I have posted earlier 

--
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/60b3d181-d232-40a0-99cd-bd8f3cca4907%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages