import time
import numpy as np
import matplotlib.pyplot as plt

npts = 10000
xx = np.arange(npts)

plt.ion()

t0 = time.time()
fig1 = plt.figure()
ax = fig1.add_subplot(1,1,1)
# Try again, commenting out the following three lines;
# you will see no significant difference in the plotting time.
ax.set_title('A title')
ax.set_xlabel('This is X')
ax.set_ylabel('This is Y')

lines = ax.plot(xx, np.random.rand(npts))
plt.draw()
t1 = time.time()

print t1-t0

for ii in range(10):
    t0 = time.time()
    lines[0].set_data(xx, np.random.rand(npts))
    plt.draw()
    t1 = time.time()

    print t1-t0


