#!/usr/bin/env python # coding: utf-8 # In[3]: get_ipython().run_line_magic('matplotlib', 'notebook') 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() plt.show() interact(update); # In[2]: from IPython.display import display, HTML ''' # JavaScript code here will execute once and will not be saved into the notebook. display(Javascript('...')) # `clear_output` replaces the need for `display_id` + `update` clear_output() ''' # JavaScript code here *will* be saved into the notebook and executed on every open. display(HTML('test.html')) # In[ ]: