I would like to change the view of a 3D plot in matlab such that the y
-axis points upward and the z
-axis points to left. For example, consider the following plot:
Here the x
-axis points forward, the y
-axis points to the right and the z
-axis points upward.
I would like to have the y
-axis points upward and the z
-axis points to the left instead. I tried to rotate the plot (using the figure window toolbar rotate button) but I could not get it to work. (It should just be a simple 90 degrees rotation about the x
-axis)
Code to generate the plot:
membrane
view(100,50)
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
grid on
Change the View Using a Vector Change the view by specifying v as the x- y- and z-coordinates of a vector, and return the new azimuth and elevation angles. The new angles are based on a unit vector pointing in the same direction as v .
r = rotate3d( fig ) creates a rotate3d object for the specified figure.
plot3( X , Y , Z ) plots coordinates in 3-D space. To plot a set of coordinates connected by line segments, specify X , Y , and Z as vectors of the same length. To plot multiple sets of coordinates on the same set of axes, specify at least one of X , Y , or Z as a matrix and the others as vectors.
You can change the orientation of the scene by specifying the direction defined as up. By default, MATLAB defines up as the y-axis in 2-D views (the CameraUpVector is [0 1 0] ) and the z-axis for 3-D views (the CameraUpVector is [0 0 1] ). However, you can specify up as any arbitrary direction.
Try using view
. I don't have MATLAB available so I can't test it, but I think it can do what you want.
Example from the documentation:
Set the view along the y-axis, with the x-axis extending horizontally and the z-axis extending vertically in the figure.
view([0 0]);
EDIT:
Try using three inputs to the view
function. I can't experiment myself, but you should be able to do it if you choose the right values here.
From documentation:
view([x,y,z])
sets the view direction to the Cartesian coordinates x, y, and z. The magnitude of (x,y,z) is ignored.
EDIT 2:
Check out camroll
. I think camroll(90)
(possibly in combination with view
) will work.
From documentation:
camroll(dtheta)
rotates the camera around the camera viewing axis by the amounts specified in dtheta (in degrees). The viewing axis is the line passing through the camera position and the camera target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With