필터 지우기
필터 지우기

Changing Axes direction with positive z-axis downwards

조회 수: 125 (최근 30일)
Ryan Hirani
Ryan Hirani 2019년 3월 13일
댓글: Sagar Chawla 2022년 4월 3일
Hello, I would like to change the direction of a 3d plot I am making. By default, Matlab has positive x-axis backwards, y-axis toward left side and z-axis toward upward direction (as in the attached picture). While maintaining the right hand coordinate system, I would like to switch the axis such that z-axis is positive downwards, x-axis toward right side and y-axis toward forward direction.
Here's a part of the code if that's any help.
Thanks for your help in advance!
[x,y,z] = sphere;
figure(1)
surf(x,y,z+1.5)
hold on
p0 = zeros(6,3);
p1 = r_LPSphere0_0';
quiver3(p0(:,1), p0(:,2), p0(:,3), p1(:,1), p1(:,2), p1(:,3))
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')

채택된 답변

Brian Hart
Brian Hart 2019년 3월 13일
Hi Ryan,
The first step is to change your second line to say
f = figure(1);
This gives you a handle to update the figure properties. To flip the z axis,
f.CurrentAxes.ZDir = 'Reverse'
To change the other two axes, first look at the current viewpoint, called the "camera position":
>> f.CurrentAxes.CameraPosition
ans =
-9.1314 -11.9003 -7.1603
If you change the z position of the view point, you get something that I think matches what you are looking for:
>> f.CurrentAxes.CameraPosition = [-9 -12 +7]
untitled.bmp

추가 답변 (1개)

Star Strider
Star Strider 2019년 3월 15일
If you only want to reverse the direcrtion of the z-axis, try this (after the surf call):
set(gca, 'ZDir','reverse')
The other axes remain unaffected.
  댓글 수: 1
Sagar Chawla
Sagar Chawla 2022년 4월 3일
How to change the position of axis. Like z in place of x and y in place of z.

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

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by