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 30 31 32 33 34
| 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('toto')
fig.clf()
ax = fig.add_subplot(111)
x = np.array([ 1, 2, 3])
y = np.array([ 10, 20, 30])
line, = ax.plot(x, y, '+', color='blue')
ax.set_ylim([0,40])
ax.set_xlim([0,6])
fig.canvas.draw()
fig.canvas.flush_events()
time.sleep(1)
new_x, new_y = np.array([4, 5, 6]), np.array([4, 5, 3])
x = np.append(x, new_x)
y = np.append(y, new_y)
print(line.get_data())
line.set_data(x,y)
print(line.get_data())
fig.canvas.draw()
fig.canvas.flush_events() |
Partager