We will plot three random datasets and display them as circles, dots, and triangles. However, we will only update two of those datasets with random values.
Plot three random datasets as circles, dots, and triangles in different colors:
circles, triangles, dots = ax.plot(x, 'ro', y, 'g^', z, 'b.')
This function gets called to update the screen regularly. Update two of the plots with new y values:
def update(data): circles.set_ydata(data[0]) triangles.set_ydata(data[1]) return circles, triangles
Generate random data with NumPy:
def generate(): while True: yield np.random.rand(2, N)
The following is a snapshot of the animation in action: