Rotate coordinate system axes
Show older comments
Sometimes it is handy to rename the x,y and z axis of a coordinate system in a plot, for example to comply with external conventions. Of course one can name the axes however they see fit, but commands like xticklabel always refer to the "native" axis name, which can be confusing (e. g. if the y axis is relabeled to "x", one now has to use yticklabel for their designated x axis etc.)
I've been (unsuccessfully) trying to figure out if it there is a way to actually rotate the default coordinate system (not the camera angle) to achieve a different orientation of the native axes. Does anyone know if this is possible? Consider the following example for clarification. The first plot has a default coordinate system while the second one has an alternative valid right hand system (which I could only achieve by reversing the z axis and swapping the y and z axis labels)
clear
close all
% Default CS
figure
ax1=axes;
hold on
grid on
view([-0.5 -1 1])
xlabel('x')
ylabel('y')
zlabel('z')
surf(ax1,[1 1;2 2],[1 2;1 2],[1 1;1 1])
title('default CS')
set(gcf,'Color','white')
% New CS
figure
ax2=axes;
ax2.ZDir = 'reverse';
hold on
grid on
view([-0.5 -1 1])
xlabel('x')
ylabel('z')
zlabel('y')
surf(ax2,[1 1;2 2],[1 2;1 2],[1 1;1 1])
title('new CS')
set(gcf,'Color','white')
3 Comments
Matt J
on 5 Nov 2021
I've been (unsuccessfully) trying to figure out if it there is a way to actually rotate the default coordinate system (not the camera angle) to achieve a different orientation of the native axes.
What is the difference between the rotation you are after and rotating the camera angle?
broken_arrow
on 8 Nov 2021
broken_arrow
on 8 Nov 2021
Edited: broken_arrow
on 8 Nov 2021
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

