this markdown cell loads the flot jQuery plugin, used for plotting

Interactive JavaScript plots with kernel callbacks

This is an example of a plotting widget, entirely in javascript, which can make callbacks to the Kernel to update data.

In this case, there is a user-defined function (update_plot) that generates the new data for the plot. The widget has sliders, which trigger calls to this function when they change. There is a javascript callback hooked up, which updates a plot area with the new data when it arrives.

You must run this one code cell to define the function before it is available to the widget, then the plot should appear when you move one of the sliders.

In [1]:
import json
from IPython.core.display import JSON, display
from scipy.special import jn
from numpy import linspace

def update_plot(n, xmax=10, npoints=200):
    x = linspace(0, xmax, npoints)
    lines = []
    for i in range(1,n+1):
        lines.append(zip(x,jn(x,i)))
    display(JSON(json.dumps(lines)))

Bessel Functions