Changing Axes direction with positive z-axis downwards
173 views (last 30 days)
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;
p0 = zeros(6,3);
p1 = r_LPSphere0_0';
quiver3(p0(:,1), p0(:,2), p0(:,3), p1(:,1), p1(:,2), p1(:,3))
Brian Hart on 13 Mar 2019
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":
-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]