I can make a plot in python its no problem. My question is : Dose there any option to make more than one plot over each other but not in the same time?!(plot the first one wait a bit then plot the second one over the first one and so on...).

plt.figure()
plt.plot(x, y, 'o') 
plt.plot(x1, y1, 'o') 
plt.plot(x3, y3, 'o')
plt.show

This code plot all over each other in the same plot. I want to wait for the first plot to explain what this plot talking about then plot the second one over the first to see the differnce between them and so on.

Ever heard of a timer object in Python? Look here.

commented: Timely. +12

Matplotlib can handle events such as keypress or mouse clicks. One only needs to write a few callbacks. Here is a small example adapted from the matplotlib's documentation. It first displays a curve, then, on a keypress event a second curve, then a third

"""
Show how to connect to keypress events
"""
from __future__ import print_function
import sys
import numpy as np
import matplotlib.pyplot as plt

def press(event):
    print('press', event.key)
    sys.stdout.flush()
    if event.key == 'x':
        visible = xl.get_visible()
        xl.set_visible(not visible)
        fig.canvas.draw()
    if todo:
        todo[0]()
        del todo[0]
        fig.canvas.draw()

fig, ax = plt.subplots()

fig.canvas.mpl_connect('key_press_event', press)

xl = ax.set_xlabel('easy come, easy go')
ax.set_title('Press a key')

x = np.arange(10.0)
y = np.sin(np.arange(10.0)/20.0*np.pi)

ax.errorbar(x, y, yerr=0.1)
ax.set_xlim(-1, 10)
ax.set_ylim(-0.5, 3.5)

def second():
    y = np.sin(np.arange(10.0)/20.0*np.pi) + 1
    ax.errorbar(x, y, yerr=0.1, uplims=True)

def third():
    y = np.sin(np.arange(10.0)/20.0*np.pi) + 2
    upperlimits = np.array([1, 0]*5)
    lowerlimits = np.array([0, 1]*5)
    ax.errorbar(x, y, yerr=0.1, uplims=upperlimits, lolims=lowerlimits)
todo = [second, third]

plt.show()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.