# a code cell import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import LightSource # example showing how to make shaded relief plots # like Mathematica # (http://reference.wolfram.com/mathematica/ref/ReliefPlot.html) # or Generic Mapping Tools # (http://gmt.soest.hawaii.edu/gmt/doc/gmt/html/GMT_Docs/node145.html) # test data d= 1 def maltc(ax, lambd=1, n=1): I0=1 I= lambda theta,d : I0*(sin(2*theta)*sin(pi*n*d/lambd))**2 X,Y=np.mgrid[-5:5:0.05,-5:5:0.05] Z=np.sqrt(X**2+Y**2)+np.sin(X**2+Y**2) r= np.sqrt(X**2+Y**2) theta = np.angle(X+1.0j*Y) Iv= np.vectorize(I) Z = Iv(r,theta) # create light source object. #ls = LightSource(azdeg=0,altdeg=65) # shade data, creating an rgb array. #rgb = ls.shade(Z,plt.cm.copper) # plot un-shaded and shaded images. #plt.figure(figsize=(12,5)) #plt.subplot(121) ax.imshow(Z,cmap=plt.cm.copper) ax.set_title('d=%d lambda=%f'%(d,lambd)) fig, (axes) = plt.subplots(3,4) fig.set_figheight(10) fig.set_figwidth(20) flatten = [item for sublist in axes for item in sublist] for ax,l in zip(flatten,range(len(flatten))): maltc(ax,lambd=(l+1)*pi/8.0) from __future__ import print_function import sys print('stdout') print('stderr',file=sys.stderr)