Controlling the appearance of the mesh in 3-D plots

There are time when you would like to change the number of mesh lines appearing on 3-D plots. This notebook illustrates how to do that. The important thing is to make your new lines line up with the edges of the polygons in the plot.

A function

Here is a function to illustrate the method.

ff[x_,y_] := Sin[x + Cos[y]]

The plot

plt1=Plot3D[ff[x,y],{x,0 ,2 π},{y,0,2 π},Mesh -> False]

New mesh lines case one

Here we create mesh lines perpendicular to the x-axis. The default number of PlotPoints is 15 so we divide by 14 to have our lines line up with the surface.

newMeshA = Table[{x,y,ff[x,y]},{x,0,2 π,2 π/14},{y,0,2π,2 π/14}];

Displaying the plot

Show[{plt1,Graphics3D[Line/@newMeshA]}]

Adding a style to the Mesh

By adding a Graphics directive we can change the form of the Mesh. This renders the Mesh as blue.

Show[{plt1,Graphics3D[{RGBColor[0,0,1],Line/@newMeshA}]}]

Reducing the mesh

Here we show how to make the number of lines on a plot fewer after we have upped the number of PlotPoints to 75.

plt2=Plot3D[ff[x,y],{x,0 ,2 π},{y,0,2 π},Mesh -> False,PlotPoints -> 75]

meshX = Table[{x,y,ff[x,y]},{x,0,2 π,5 2 π/74},{y,0,2π,2 π/74}];

meshY = Table[{x,y,ff[x,y]},{y,0,2 π,5 2 π/74},{x,0,2π,2 π/74}];

The plot

Show[{plt2,Graphics3D[{RGBColor[0,0,1],Line/@meshX,Line/@meshY}]}]

Compare the above with the default number of mesh lines.

plt3=Plot3D[ff[x,y],{x,0 ,2 π},{y,0,2 π},Mesh -> True,PlotPoints -> 75]