I am trying to build a GUI app for graph plotting where graph can be shown as a slideshow so that the data can be clearly visualised. First I wish to plot a set of data then after a specific time interval next set of data and so on.

I have a text file contains data as:

 0.00   -10.742    10.7888  6.33455
 1.00   -17.75391  10.0000  4.66778
 4.00   -19.62891  15.9999  4.232323
 20.00  -20.7641   18.6666  3.99999
 23.00  -34.2300   2.7777   2.00000
 50.00  -50.000    1.87878  2.77778
 65.88   -22.5000  2.99999  1.45555
 78.00   -30.000   1.55555  2.45667
 86.00   -37.7900  2.55556  7.55679
 90.00   -45.00000 13.6667  2.677888
 ----
 ----
 200.02   200.01   0.0000   2.6667
 300.00   300.02   1.6666   2.7878

What I have tried is:

    from PyQt5.QtWidgets import *
    from PyQt5.uic import loadUi
    from matplotlib.backends.backend_qt5agg import (NavigationToolbar2QT as NavigationToolbar)
    import matplotlib.pyplot as plt
    import numpy as np
    from matplotlib import style

    import os
    class MatplotlibWidget(QMainWindow):

        def __init__(self):
            QMainWindow.__init__(self)
            loadUi("graphgenerate.ui", self)
            self.setWindowTitle("PyQt5 & Matplotlib Example GUI")
            self.playbutton.clicked.connect(self.drawGraph)
            self.addToolBar(NavigationToolbar(self.MplWidget.canvas, self))

        def drawGraph(self):
            f1 = open('TESTIP2.txt', 'r')
            print(f1)
            data = np.genfromtxt(f1)
            m = np.size(data, 0)
            n = np.size(data, 1)
            x = data[:, 0].reshape(m, 1)
            y = data[:, 1].reshape(m, 1)
            iters = m // 4
            xs=[]
            ys=[]
            for i in range(iters):
                xs.append(x[i])
                ys.append(y[i])
            self.MplWidget.canvas.axes.clear()
            self.MplWidget.canvas.axes.plot(xs,ys)
            self.MplWidget.canvas.axes.legend(('cosinus', 'sinus'), loc='upper right')
            self.MplWidget.canvas.axes.set_title('Signal' )
            self.MplWidget.canvas.draw()

    if __name__ == "__main__":

        app = QApplication([])
        window = MatplotlibWidget()
        window.show()
        app.exec_()        

Currently only first set of data is working . I wish to plot next set of data from same file after a specific time interval, say 10s. Likewise I am trying to show next and so on. Anyone please help me out there to fix this.

After I read your post a few times, I have to write that "as a slideshow" is misleading. But hey, it's English

If I were to add the feature to graph further along the time scale I think I'd focus on line 29. That appears to be where you select what to plot.
Why not change that to the range you want to plot?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.