Level Curves

Code

graphics[numberOfCurves_,showShading_]:=(
shading=If[showShading,Automatic,False];
levelCurves=ContourPlot[f[x,y],{x,-3,3},{y,-3,3},Contours->numberOfCurves,ContourShading->shading];
Show[levelCurves,Axes->Automatic,AxesLabel->{x,y}])

Graphics

f[x_,y_]:=4Sin[x^2+y^2]/(x^2+y^2);
numberOfCurves=10;
showShading=True;
graphics[numberOfCurves,showShading]

Level Curves on Surfaces

Code

contoursIn3D[contourPlot_,height_]:=(
points=Append[#,height] & /@contourPlot[[1,1]];
lines = Cases[contourPlot,Line[L_],Infinity];
GraphicsComplex[points,lines]
)
graphics[numberOfCurves_,showInXY_,showOnSurface_,showSurface_,showPlanes_]:=(
contourHeights=Range[-1,4,6/(numberOfCurves+1)];
contoursInXY=If[showInXY,Graphics3D[{Gray,Thickness[0.008],contoursIn3D[ContourPlot[f[x,y],{x,-3,3},{y,-3,3},Frame->False,Axes->False,PlotRangePadding->0,Contours->contourHeights],0]}],{}];
opacity=If[showSurface,1,0];
mesh=If[showOnSurface,{contourHeights},None];
surface=Plot3D[f[x,y],{x,-3,3},{y,-3,3},MeshFunctions->{#3 &},Mesh->mesh,MeshStyle->{Green,Thickness[0.008]},PlotStyle->Opacity[opacity],BoundaryStyle->None];
planes=If[showPlanes,Plot3D[#,{x,-3,3},{y,-3,3},PlotStyle->Opacity[.9],Mesh->None]&/@contourHeights,{}];

Show[contoursInXY,surface,planes,Axes->Automatic,AxesLabel->{x,y,z},BoxRatios->{1,1,1},PlotRange->{{-3,3} ,{-3,3},{-1,4}},ViewPoint->{20,4,8}])

Graphics

f[x_,y_]:=4Sin[x^2+y^2]/(x^2+y^2);
numberOfCurves=6;
showInXYPlane=True;
showOnSurface=True;
showSurface=True;
showPlanes=True;
graphics[numberOfCurves,showInXYPlane,showOnSurface,showSurface,showPlanes]