#This line is always necessary when you use matplotlib in a notebook, otherwise the figures will not appear. %pylab inline import matplotlib.pyplot as plt import numpy as np #Solutions def Lissajous( t, A=1.0, B=1.0, a=1.0, b=1.0, delta=0.0 ): x = A*np.sin(a*t+delta) y = B*np.sin(b*t) return x, y #Parameters to be sampled-------------------- #delta Ndelta = 4 #Number of delta parameters Delta = np.linspace(0,np.pi,Ndelta) #Ratio c=a/b Nratio = 6 #Number of c parameters C = np.linspace(0,1,Nratio) #Time array T = np.linspace(0,40,1000) #Initializing plotting environment plt.figure( figsize=(4*Ndelta, 4*Nratio) ) plt.subplot( Nratio, Ndelta, 1 ) plt.plot() #Sweeping all figures for i in xrange( Ndelta ): for j in xrange( Nratio ): #Creating a subfigure with the current delta and ratio c plt.subplot( Nratio, Ndelta, j*Ndelta+i+1 ) #Plotting this Lissajous curve X, Y = Lissajous( T, b=C[j], delta=Delta[i] ) plt.title( "$\delta=$%1.2f\t$a/b=$%1.2f"%(Delta[i],C[j]) ) plt.plot( X, Y, linewidth=2 ) from IPython.core.display import Image Image(filename='./figures/nbviewer.png')