(data)
| 40 | |
| 41 | |
| 42 | def run(data): |
| 43 | # update the data |
| 44 | t, y = data |
| 45 | xdata.append(t) |
| 46 | ydata.append(y) |
| 47 | xmin, xmax = ax.get_xlim() |
| 48 | |
| 49 | if t >= xmax: |
| 50 | ax.set_xlim(xmin, 2*xmax) |
| 51 | ax.figure.canvas.draw() |
| 52 | line.set_data(xdata, ydata) |
| 53 | |
| 54 | return line, |
| 55 | |
| 56 | # Only save last 100 frames, but run forever |
| 57 | ani = animation.FuncAnimation(fig, run, data_gen, interval=100, init_func=init, |