Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to show graph as a slideshow in PyQt5 using matplotlib
#1
I am trying to implement a GUI app for graph plotting which should show graph as slideshow so that data can be visualized clearly for the users. Currently whole content of the file is read and plotted as a single figure,but I show to split the figure and show as slideshow ie first i want to plot first n set of data then next set likewise i wish to plot till the end of the file.
I have 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_()
Please help to fix this. I will be thankful,if anyone help me out there.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Dynamic graph matplotlib quant7 1 532 May-17-2019, 06:24 PM
Last Post: quant7
  Huge code problems (buttons(PyQt5),PyQt5 Threads, Windows etc) ZenWoR 0 330 Apr-06-2019, 11:15 PM
Last Post: ZenWoR
  Need help with a simple slideshow that uses pyglet Steven_04 1 359 Mar-23-2019, 03:43 PM
Last Post: Larz60+
  Show a plot from matplotlib in a webpage cliquot22 2 548 Dec-28-2018, 05:03 AM
Last Post: cliquot22
  [PYQT5] Crashing when using .hide() and .show() aking76 0 1,441 Sep-18-2018, 02:09 PM
Last Post: aking76
  [PyQt] Can't show PyQt5 mediaPlayer in window DecaK 1 1,073 Sep-15-2018, 09:54 AM
Last Post: Axel_Erfurt
  Show GPG keys in pyqt5 window Fred Barclay 1 1,873 Oct-24-2016, 07:09 PM
Last Post: micseydel

Forum Jump:


Users browsing this thread: 1 Guest(s)