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 日

0 投票

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.
How can I do the same with contour3 function to define y axis as the one to plot my contours over the surface?
Math Passion
Math Passion 2020 年 12 月 11 日
I mean how can I change the Y and Z axis in the above example you provided with contour3.
Cris LaPierre
Cris LaPierre 2020 年 12 月 11 日
The simplest way is to plot your data like this
contour3(X,Z,Y)
Math Passion
Math Passion 2020 年 12 月 11 日
Then the contour lines are ploted based on the Y values and not the Z that I want.
I want to somehow rotate my coordinate system 90 degrees downwards without using view function.
Cris LaPierre
Cris LaPierre 2020 年 12 月 11 日
Why you can't use the view function?
Math Passion
Math Passion 2020 年 12 月 11 日
I can use it technically but I could not find the best viewangle.
The best one is the one that gives me the rotation of my coordinate 90 degrees downwars.
Cris LaPierre
Cris LaPierre 2020 年 12 月 11 日
編集済み: Cris LaPierre 2020 年 12 月 11 日
I don't see any setting that lets you define which axis the contours show up on. I'll never say it isn't possible, but I don't currently know how to do it. I do think there is a way to do what you want using the normal axis arrangement and rotating your axes.
You can rotate manually and, once you get the view you want, use those parameters in your view command.
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 日

0 投票

That works perfectly!
Thanks alot!

カテゴリ

質問済み:

2020 年 12 月 10 日

回答済み:

2021 年 1 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by