To control how your SCATTER3 markers are colored you can make use of the CData property of your graphic object.
CData controls the color of markers. If you would like to map your points with a colormap you can use a vector with the same length of your XData and YData then the values in CData are linearly mapped to the colors in the current colormap.
Please consider the following code as an example:
[x,y,z] = sphere(16);
X = [x(:)*.5 x(:)*.75 x(:)];
Y = [y(:)*.5 y(:)*.75 y(:)];
Z = [z(:)*.5 z(:)*.75 z(:)];
scatter3(X(:),Y(:),Z(:),'CData',Z(:))
colorbar
In this case the Z value has been used to define the colormap but you can consider any other different map you may like by inserting a different vector with the same size of X and Y.
Best Answer