# Slot in the code

I am given the following code in my notes:

  Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3},
PlotLabel -> "Plot of Sin[x y]",  AxesLabel -> {"x", "y"},
ColorFunction -> (GrayLevel[#] &)]
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3},
PlotLabel -> "Plot of Sin[x y]",  AxesLabel -> {"x", "y"},
ColorFunction -> (GrayLevel[#1] &)]
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3},
PlotLabel -> "Plot of Sin[x y]",  AxesLabel -> {"x", "y"},
ColorFunction -> (GrayLevel[#2] &)]
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3},
PlotLabel -> "Plot of Sin[x y]",  AxesLabel -> {"x", "y"},
ColorFunction -> (GrayLevel[#3] &)]


I dont understand what the # values in the above context is. What values are being put in each case in the above code.

In general context the hash is called a slot and it is where the values are plugged in to the function

• Yes... and the values passed to the ColorFunction are (internally) the value of the point being plotted. For functions such as Plot3D, the values are two-dimensional vectors, so #1 and #2 are the coordinates. Commented May 22, 2021 at 19:19
• And, so is #3. Commented May 22, 2021 at 19:28

Always good to play around and see what things actually do.

Simplifying your code to highlight the GrayLevel / Slot question:

Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3},ColorFunction -> (GrayLevel[#] &)]
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3},ColorFunction -> (GrayLevel[#1] &)]
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3},ColorFunction -> (GrayLevel[#2] &)]
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3},ColorFunction -> (GrayLevel[#3] &)]


Which gives:

A little further investigation:

(GrayLevel[#] &) == (GrayLevel[#1] &)
True


So it doesn't look like you need both.

In the case of Plot3D, ColorFunction applies a color or in your cases, variation of gray to differences in the specified co-ordinates of the surface of the plot.

So, it looks like,

# or #1 applies it to the x axis, #2 to the y axis and #3 to the z axis.