How to interchange Z and Y axes direction in MATLAB?

In summary, The conversation discusses using a 3D plot in MATLAB and how to rotate the axes to achieve a desired orientation. The speaker mentions using the isosurface function from MATLAB help and manipulating the data and axis labels, but prefers to find a way to do it without directly manipulating the data. They are advised to use a combination of the view and camroll commands, with examples available in the documentation.
  • #1
xnov
1
0
i have 3D plot in matlab
lets say i use example isosurface from MATLAB help

[x,y,z,v] = flow;
p = patch(isosurface(x,y,z,v,-3));
isonormals(x,y,z,v,p)
set(p,'FaceColor','red','EdgeColor','none');
daspect([1 1 1])
view(3); axis tight
camlight
lighting gouraud
xlabel('x-axis');ylabel('y-axis');zlabel('z-axis');

but the problem is that z axis is in vertical direction, and x & y is horizontal direction. i want to interchange so that x and z is horizontal direction and y is in vertical direction. well i can manipulate data dan axis label, but i prefer to do without manipulate the data. is there anyone knows how to do it?
thanks
 
Physics news on Phys.org
  • #2
Although you're asking in relation to one of the demo files, rotating the graphics axes for a plot is generally tightly coupled to the particular plot you're working with. You can achieve what you want using a suitable combination of the view and camroll commands.

Check the docs for examples on how to use them.
 

1. How do I change the direction of the Z and Y axes in MATLAB?

To change the direction of the Z and Y axes in MATLAB, you can use the view function. This function allows you to specify the azimuth and elevation angles of the axes, which determines their direction. You can also use the axis function to set the direction of the axes manually.

2. Can I interchange the Z and Y axes in a 3D plot?

Yes, you can interchange the Z and Y axes in a 3D plot by using the view function. This allows you to change the orientation of the axes in any direction you want.

3. How do I reverse the direction of the Z axis in a 3D plot?

To reverse the direction of the Z axis in a 3D plot, you can use the set(gca,'ZDir','reverse') command. This will change the direction of the Z axis to be opposite of what it was previously.

4. Is there a way to change the direction of the axes in a 3D plot without altering the data?

Yes, you can change the direction of the axes in a 3D plot without altering the data by using the set(gca,'DataAspectRatio',[1 1 -1]) command. This will flip the direction of the Z axis without changing the data values.

5. How can I change the direction of the axes in a 3D plot to match a specific orientation?

To change the direction of the axes in a 3D plot to match a specific orientation, you can use the view function and specify the azimuth and elevation angles that correspond to the desired orientation. You can also use the axis function to manually set the direction of the axes to match a specific orientation.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
585
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
877
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top