How do I plot a contour map on the surface of a 3-d surface?

조회 수: 29 (최근 30일)
Joseph
Joseph 2016년 1월 31일
댓글: GiWon Hong 2020년 2월 14일
The idea is similar to using "surf(X,Y,Z,C)" but I want contour lines in addition to the coloring provided by C. The contour lines need to correspond to f(x,y,z), not x, y, or z. If there is a non-toolbox specific answer, that would be great. Thanks.

채택된 답변

Mike Garrity
Mike Garrity 2016년 2월 1일
편집: Mike Garrity 2016년 2월 1일
A simple tricky I use sometimes is to use a colormap with a small number of colors.
[x,y] = meshgrid(linspace(-pi,pi,150));
z = cos(x).*cos(y);
c = sin(x).*sin(y);
surf(x,y,z,c,'FaceColor','interp','EdgeColor','none')
zlabel('cosine')
colormap(lines(7))
c = colorbar;
c.Label.String = 'sine';
view([-45 60])
This makes my CData variable look like what the contourf function would draw.
  댓글 수: 3
John Mickett
John Mickett 2019년 8월 7일
I would like to put contour lines OVER a surf plot (two different variables), so that solution doesn't work. Any suggestions? I do it in 2D all the time.
GiWon Hong
GiWon Hong 2020년 2월 14일
Thanks, It is very helpful.
I used colormap(jet(31)) instead of colormap(lines(7)). It gives more contour likely view.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by