Visibility of a simple 'plot' on tip of a 'surface'

1 view (last 30 days)
I have a surface and am going to put a simple plot (which is a line connecting a few dots) on top of the surface. How can I do that?
I draw the surface and use 'hold on', and then draw the simple plot, but the simple plot goes behind the surface...

Answers (1)

Walter Roberson
Walter Roberson on 21 Mar 2014
Give the plot a slightly larger z value than the surface. Well, not exactly z value, really, but a coordinate which is slightly closer along the viewing angle than the surface itself is.
When you have a line and a surface at the same distance along the projection, then if you are in OpenGL (not unlikely for surface plots) then OpenGL has its own ideas of which should be drawn first, and nothing you can do by using uistack() can alter what OpenGL will do. So you separate them slightly so that one is "closer".

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!