MATLAB: Is the surface black when plotting with the SURF command regardless of the color map chosen

colormapMATLAB

The SURF command creates a plot in which the surface is black regardless of the color map that I choose.

Best Answer

The issue occurs when the grid which your surface is plotted over contains a large number of points. The lines which create the wire mesh surface are black by default and take precedence over the color map.
Example:
x = 1:.01:3*pi;
[X Y] = meshgrid(x,x);
Z = sin(X.*Y).*cos(X.*Y);
h = surf(Z)
In this situation, the wire grid is so dense that the lines form a completely black surface.
To solve this either turn the lines off using the command
set(h,'LineStyle','none')
If you would like a visible wire mesh on your surface plot, use a grid with fewer points.
An example of this would be:
x = -3:.2:3;
[X Y] = meshgrid(x,x);
Z = peaks(X,Y);;
h = surf(Z)