By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,491 Members | 1,108 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,491 IT Pros & Developers. It's quick & easy.

How to show graph as a slideshow in PyQt5.

P: 1
I am trying to build a software 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:

Expand|Select|Wrap|Line Numbers
  1.     class MatplotlibWidget(QMainWindow):
  2.             ----
  3.             self.playbutton.clicked.connect(self.drawGraph)
  4.             ---       
  5.  
  6.         def drawGraph(self):
  7.             f1 = open('TESTIP2.txt', 'r')            
  8.             data = np.genfromtxt(f1)
  9.             m = np.size(data, 0)           
  10.             x = data[:, 0].reshape(m, 1)
  11.             y = data[:, 1].reshape(m, 1)
  12.             iters = m // 4
  13.             xs=[]
  14.             ys=[]
  15.             for i in range(iters):
  16.                 xs.append(x[i])
  17.                 ys.append(y[i])
  18.             self.MplWidget.canvas.axes.clear()
  19.             self.MplWidget.canvas.axes.plot(xs,ys)
  20.             self.MplWidget.canvas.axes.legend(('cosinus', 'sinus'), loc='upper right')
  21.             self.MplWidget.canvas.axes.set_title('Signal' )
  22.             self.MplWidget.canvas.draw()
  23.  
  24.     if __name__ == "__main__":
  25.  
  26.         app = QApplication([])
  27.         window = MatplotlibWidget()
  28.         window.show()
  29.         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 10 sec. Likewise I am trying to show next and so on.
1 Week Ago #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.