Skip to content

Instantly share code, notes, and snippets.

@Philmod
Last active January 8, 2018 03:02
Show Gist options
  • Save Philmod/c76313c41fe7a3a2ec229a58b3c77292 to your computer and use it in GitHub Desktop.
Save Philmod/c76313c41fe7a3a2ec229a58b3c77292 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
import time
%matplotlib notebook
x = np.linspace(0, 10*np.pi, 100)
y = np.sin(x)
plt.ion()
fig,ax = plt.subplots(1,1)
line1, = ax.plot(x, y, 'b-')
fig.canvas.draw()
for phase in np.linspace(0, 10*np.pi, 5):
line1.set_ydata(np.sin(0.5 * x + phase))
ax.set_title('phase ' + str(phase))
fig.canvas.draw()
plt.pause(0.01)
@dsblank
Copy link

dsblank commented Jan 8, 2018

This isn't an ipynb file, but just a Python file.

Also, there is a bug in matplotlib that has a drawing glitch: matplotlib/matplotlib#9606

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment