Skip to content

Instantly share code, notes, and snippets.

@davidcorbin
Created September 5, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcorbin/1cd6e46d9cc42310dbf8ae5394a591f2 to your computer and use it in GitHub Desktop.
Save davidcorbin/1cd6e46d9cc42310dbf8ae5394a591f2 to your computer and use it in GitHub Desktop.
Interactive Plots in Jupyter
%matplotlib widget
from ipywidgets import *
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2 * np.pi)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
line, = ax.plot(x, np.sin(x))
def update(w = 1.0):
line.set_ydata(np.sin(w * x))
fig.canvas.draw_idle()
interact(update);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment