![]() |
How to show graph as a slideshow in PyQt5 using matplotlib - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: How to show graph as a slideshow in PyQt5 using matplotlib (/thread-16641.html) |
How to show graph as a slideshow in PyQt5 using matplotlib - binsha - Mar-08-2019 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 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. |