I'm looking for something similar to FuncAnimation with blit, but instead of having a the library call a function at a fixed timestep, I want to call the function myself whenever I'm ready. I don't understand what matplotlib does with the axes returned by the function to update them. I'm working with live data coming from outside sources and I want the refresh rate to be synced with that data.
Asked
Active
Viewed 489 times
5
-
You might want to use something along the lines of this question instead of using FuncAnimation itself: http://stackoverflow.com/questions/10944621/dynamically-updating-plot-in-matplotlib – Ajean Jun 17 '14 at 20:18
1 Answers
0
I have done it something like this
import sys
import os
import random
from PySide import QtGui,QtCore
os.environ['QT_API'] = 'pyside'
from matplotlib import use
use('Qt4Agg')
import pylab as plt
class Example(QtGui.QMainWindow):
def __init__(self):
super(Example, self).__init__()
self.setWindowTitle('Widgets')
self.setGeometry(300, 300, 250, 150)
self.wid = QtGui.QWidget()
self.grid = QtGui.QGridLayout()
self.wid.setLayout(self.grid)
self.setCentralWidget(self.wid)
self.dat = []
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.toc)
self.timer.start(100)
self.show()
self.fig = plt.figure(13)
plt.show()
def toc(self):
val = random.uniform(-1.7, 0.78)
self.dat.append(val)
plt.ion()
fig = plt.figure(13)
plt.clf()
plt.plot(self.dat)
plt.ioff()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()

Svend Feldt
- 758
- 4
- 17