managing surface plot axis

조회 수: 5 (최근 30일)
Math Passion
Math Passion 2020년 12월 10일
답변: Math Passion 2021년 1월 12일
I wonder if it is possible to plot a surface in matlab while changing the x, y and z axis.
I don't want to have my z value upwards. I want to have it in x direction instead.
The problem here is the colorbar which is based on the z value. Even if I change the order of my data points, matlab always consider the z value for the colorbar.
Thank you very much in advance.

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 12월 10일
Have you tried using your X data as the surface color input C? Adapting this doc example.
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
surf(X,Y,Z,X)
xlabel("X")
ylabel("Y")
zlabel("Z")
colorbar
  댓글 수: 9
Math Passion
Math Passion 2020년 12월 11일
Thank you very much anyway. I hope I find a solution. This is very annoying as the problem will be easily solved just by changing the axis.
Cris LaPierre
Cris LaPierre 2021년 1월 11일
A coworker pointed out to me that perhaps adjusting the camera properties might create the view you want.
[X,Y] = meshgrid(-5:0.25:5);
Z = X.^2 + Y.^2;
contour3(X,Y,Z,50);
ax = gca;
camup([1 0 0]); % or set the CameraUpVector property of axes
ax.CameraPosition = [30 -70 -140];
ax.CameraViewAngle = 10;

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

추가 답변 (1개)

Math Passion
Math Passion 2021년 1월 12일
That works perfectly!
Thanks alot!

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by