I wish to show graph as a slideshow by reading data from the file. First I wish to plot first set of data,then next and so on. What I have tried is:
class MatplotlibWidget(QMainWindow):
def __init__(self):
---
self.playbutton.clicked.connect(self.drawGraph)
self.pausebutton.clicked.connect(self.pauseGraph)
----
def drawGraph(self):
f1 = open('TESTIP2.txt', 'r')
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
current_iter=0
self.plotGraph(x,y,iters,current_iter)
def plotGraph(x,y,iters,current_iter):
for i in range(iters):
self.plotDraw(x[current_iter:current_iter+iters],y[current_iter:current_iter+iters])
current_iter=current_iter+iters
time.sleep(1)
def plotDraw(x,y)
self.MplWidget.canvas.axes.clear()
self.MplWidget.canvas.axes.plot(x,y)
self.MplWidget.canvas.axes.legend(('cosinus', 'sinus'), loc='upper right')
self.MplWidget.canvas.axes.set_title('Signal' )
self.MplWidget.canvas.draw()
plotDraw function is called inside the loop to show each set of data, but its shows only the last set of data. Is there any way to show first, second, and so on after a specific time interval.

plt.pause(1)in the for loop?