3 Replies - 232 Views - Last Post: 11 March 2019 - 02:04 AM Rate Topic: -----

#1 itsbinsha   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-March 19

How to show graph as a slideshow in PyQt5.

Posted 10 March 2019 - 09:02 AM

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:

Quote

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 10 sec. Likewise I am trying to show next and so on.

Is This A Good Question/Topic? 0
  • +

Replies To: How to show graph as a slideshow in PyQt5.

#2 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6776
  • View blog
  • Posts: 27,942
  • Joined: 12-December 12

Re: How to show graph as a slideshow in PyQt5.

Posted 10 March 2019 - 12:14 PM

Have you discovered how to introduce a delay?
Was This Post Helpful? 0
  • +
  • -

#3 itsbinsha   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-March 19

Re: How to show graph as a slideshow in PyQt5.

Posted 10 March 2019 - 09:36 PM

How to fix this.Can you help with a code?
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6776
  • View blog
  • Posts: 27,942
  • Joined: 12-December 12

Re: How to show graph as a slideshow in PyQt5.

Posted 11 March 2019 - 02:04 AM

You have completely ignored my question. Also, be aware of this forum's rules about directly asking for code. We are here to help not to hand out code.

If you want to introduce pauses then the first thing to discover is the basic feature and sample code that would provide such pauses/intervals. I did a quick search of "pyqt delay" (or timer, or interval) and noted that there is something called QTimer. Investigate this first and see if you can get some simple code running that introduces a delay.




Eventually, you probably will have some kind of loop that draws a chunk of data, then pauses, and then goes to get the next chunk. The loop process should end when it is realised that there is no further data to process.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1