2
votes

I am plotting orientable open surfaces in MATLAB, where each side of the surface is well defined. I want to have each side be a different color so it is easy to tell if you are looking at the "front" or back. I can't seen to get this in MATLAB. I've tried back face lighting but this does not produce a difference. I'm not sure if it's because my data is an open surface rather than a closed one. It could also be the choice of other variables. Here is a code snippet.

       h = surf(xc,yc,-zc);
       set(h,'faceColor',[0.75 0.75 0.75],'BackFaceLighting','lit');   

I've tried different choices for the option. Ultimately what I'd like is to have the front face (the one visible) be a dark shade of grey and the back a different lighter shade of grey. There are cases when the surfaces fold or contort and part of the back is visible. Also, if another plotting function, other than surf(), does this please let me know.

SciLab actually does this by default with blue and yellow (or some other combo of colors). So I've not had to worry about specifying options.

1

1 Answers

2
votes

You can plot two surfaces, one slightly lower then the other.

Example:

[X, Y, Z] = peaks(25);
figure;
surf(X, Y, Z, 'faceColor', [0.15 0.15 1]);
hold on
Z2 = Z - 0.01; %Set Z2 values slightly lower then Z
surf(X, Y, Z2, 'faceColor', [0.75 0.75 0.75], 'BackFaceLighting', 'lit');
hold off

Result:
enter image description here