PLOTS animatePlotΒΆ

# -*-Python-*-
# Created by pablorf at 28 Jul 2017  19:13

import matplotlib.pyplot as plt
import matplotlib.animation as animation
import time
import random

fig = plt.figure()
ax0 = fig.use_subplot(1, 1, 1)


def animate(i):

    """
    Here you must define x and y. In case that you have a routine that
    modifies a file, then you should write here the appropriate commands
    to read the file. If the file is being updated, then the plot will be
    updated.
    What I have here is just a silly set of (x,y) that is random in each
    iteration.
    """
    x = [random.randint(0, 10), random.randint(0, 10), random.randint(0, 10)]
    y = [random.randint(0, 10), random.randint(0, 10), random.randint(0, 10)]

    ax0.clear()
    ax0.plot(x, y)


ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()