1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| import matplotlib.pyplot as plt
import numpy as np
import time
# Fait en sorte que le traçage soit interactif.
# Sinon la figure est affichée qu'à la toute fin.
plt.ion()
fig = plt.figure()
x = np.array([ 1, 2, 3])
y = np.array([ 10, 20, 30])
line, = plt.plot(x, y, color='blue', lw=2)
def update_points(new_x, new_y):
global x, y, fig, line1, ax
x = np.append(x, new_x)
y = np.append(y, new_y)
print(x)
print(y)
line.set_data(x,y)
fig.canvas.draw()
update_points(np.array([4, 5, 6]), np.array([4, 5, 3]))
plt.show()
time.sleep(10) |
Partager