Contour plot on top of surface plot

조회 수: 88 (최근 30일)
PPM
PPM 2020년 2월 21일
댓글: Geraldo Rebouças 2023년 11월 27일
Hi all,
I want to achieve something like the attached picture. I have tried with a mesh on top of a surf plot without success. I am not sure if this can be achieved with the surfc function. Any hints?
Thanks

채택된 답변

PPM
PPM 2020년 2월 24일
편집: PPM 2020년 2월 24일
Thank you for your answers.
As Walter said, Jacob's answer works but I have to work out the way to have a proper colorbar.
I ended up using the tips on this link Surface plot with multiple colormaps
Cheers
PPM

추가 답변 (2개)

Jacob Wood
Jacob Wood 2020년 2월 21일
You can get similar results with surf() and contourf()
[X,Y,Z] = peaks(25);
surf(X,Y,Z-10)
hold on
contourf(X,Y,Z)

Walter Roberson
Walter Roberson 2020년 2월 21일
편집: Walter Roberson 2020년 2월 21일
Although it is possible to hack the properties of contour to change where the z values appear, it is typically much easier to create a hgtransform() group, and when you contour() use that group's handle as the first parameter to contour() (the position you would specify the axes). Then set the transform matrix of the hgtransform group to translate Z upwards by however many units are appropriate. If you use datatips, then they will reflect the original data values, not the translated values.
The code suggested by Jacob Wood does work for its purpose, and can be used with contour() as well as contourf(), but it relies upon subtracting enough from the Z coordinates that all of the Z coordinates passed to surf() are negative. Then you either have to live with the z axes be offset by that subtracted amount, or else you have to set the Z tick labels to hide the fact that your data is offset. Your ability to use datatips is affected when you use this approach.
  댓글 수: 4
Geraldo Rebouças
Geraldo Rebouças 2022년 7월 6일
Thanks!

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

카테고리

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

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by