Figures and sliders

Pylab environment

The following command loads basic matplotlib and numpy functions.

%pylab inline

Simple plot

x=linspace(0,1,100) #sampling points
y=x**2              #evaluating the function in the sampled points
plot(x,y)           #plotting

Simple plot, bivariate function

x2,y2=meshgrid(linspace(-2,5,100),linspace(-1,4,100) #2D sampling
z2 = sin(x2) ** 10 + cos(10 + y2 * x2) * cos(x2)      #evaluation
pcolor(x2,y2,z2)                                      #plotting

Interactivity

from ipywidgets import *           # package responsible for interactivity

def freki(omega):                  #function to play with
   plot(t,sin(omega*t))   

interact(freki,omega=(0,10,0.1));  #play