![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173997/image.png)
How to place Contourf at a new height?
조회 수: 3 (최근 30일)
이전 댓글 표시
I have the following plot and the Contourf.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163010/image.jpeg)
By default, Contourf will always be generated at height Z = 0 i.e. the horizontal plane. I would like to shift Contourf to height Z = -2, this is so the contour will be placed under the graph of my function. How do I achieve this?
Code:
x = linspace(0,1,1000);
y = linspace(0,1,1000);
[X,Y] = meshgrid(x,y);
Z = -X.^2 - Y.^2;
mesh(X,Y,Z)
box on
hold on
contourf(X,Y,Z)
댓글 수: 0
답변 (1개)
Star Strider
2017년 4월 16일
This seems to work:
x = linspace(0,1,1000);
y = linspace(0,1,1000);
[X,Y] = meshgrid(x,y);
Z = -X.^2 - Y.^2;
mesh(X,Y,Z+2)
box on
hold on
contourf(X,Y,Z+2)
zt = get(gca, 'ZTick');
set(gca, 'ZTick',zt, 'ZTickLabel',zt-2)
view([15 35])
Change the view arguments to the orientation you want.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173997/image.png)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!