How do I view "hidden" contour lines on a surface?

2 views (last 30 days)
Joe
Joe on 27 Feb 2014
Commented: Joe on 27 Feb 2014
The following Matlab code produces a 3d surface plot with a superimposed contour line. The resulting contour line has several missing segments. If I manually rotate the surface, I can see the missing segments behind the surface. Is there some way to make the entire contour line visible?
x=linspace(0,3,10); y=linspace(0,2,10);
z=[ 2.08, 2.04, 1.91, 1.64, 1.21, 0.74, 0.66, 0.55, 0.33, 0.00; 2.01, 1.87, 1.66, 1.39, 1.03, 0.73, 0.65, 0.47, 0.17, 0.00; 1.79, 1.68, 1.29, 1.11, 0.85, 0.73, 0.56, 0.20, 0.00, 0.00; 1.75, 1.62, 1.20, 0.99, 0.66, 0.59, 0.47, 0.00, 0.00, 0.00; 1.51, 1.35, 1.08, 0.67, 0.53, 0.57, 0.22, 0.00, 0.00, 0.00; 1.06, 0.81, 0.69, 0.38, 0.46, 0.40, 0.00, 0.00, 0.00, 0.00; 0.45, 0.38, 0.21, 0.12, 0.31, 0.04, 0.00, 0.00, 0.00, 0.00; 0.06, 0.04, 0.00, 0.01, 0.09, 0.00, 0.00, 0.00, 0.00, 0.00; 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00; 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00];
figure; surf(x, y, z); hold on
view(120,40); colormap(winter)
[C,h]=contour3(x, y, z, [1.0 1.0], 'r');

Answers (1)

John D'Errico
John D'Errico on 27 Feb 2014
I'd suggest turning the surface mildly transparent. In the call to surf, try this instead:
surf(x, y, z,'facealpha',.5)
The rest stays the same.
  2 Comments
Walter Roberson
Walter Roberson on 27 Feb 2014
One effect of using transparency would be to force OpenGL renderer. But if that was not what was being used then just the switch of renderer might be the trick rather than the transparency itself. Try
set(gcf, 'Renderer', 'opengl')
Joe
Joe on 27 Feb 2014
John and Walter, Thanks for your quick responses! I first tried changing the transparency as John suggested. That works, now I can I see the entire contour line. However, the surface color scale washes out, so it's hard to distinguish dark blue from light blue, and the red contour line becomes grey when it passes behind the surface. I tried various alpha values, but I haven't found one where both the surface and the contour line look good.
Next, I tried varying the renderer, as Walter suggested (with alpha=1). The painters renderer actually shows more of the contour line than OpenGL, but parts of it still disappear behind the surface.
Any other ideas?
- Joe

Sign in to comment.

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!