How to show axis in 3D
170 views (last 30 days)
Show older comments
Niklas Kurz
on 26 Jun 2021
Commented: Star Strider
on 29 Jun 2021
Any time I plot in 3D I get a little confused because of aggravated orientation. The main reason is the missing default visualisation of thick axis lines (as far as I know)
That's why I tampered with it myslef, coming up with:
%some plotting
axis([0 1 0 1 0 1])
hold all
quiver3(0,0,-max(zlim),0,0,2*max(zlim),'b','LineWidth',1)
quiver3(0,-max(ylim),0,0,2*max(ylim),0,'b','LineWidth',1)
quiver3(-max(xlim),0,0,2*max(xlim),0,0,'b','LineWidth',1)
text(0,0,max(zlim),'Z','Color','b')
text(0,max(ylim),0,'Y','Color','b')
text(max(xlim),0,0,'X','Color','b')
axis equal
Now regarding my question: Is there an easier way to implement this visualization or optimize my attempt? Even putting it in a script so I can type 'axlines on' or somewhat to handle it easily. Or it's all redundant because it already exist somehow?
0 Comments
Accepted Answer
Star Strider
on 26 Jun 2021
I am not certain what you are asking.
If you want to see it in ‘true’ 3D, use the view function, and to change the axes LineWidth or GridLineStyle (or both), those (and other) options are also available:
%some plotting
axis([0 1 0 1 0 1])
hold all
quiver3(0,0,-max(zlim),0,0,2*max(zlim),'b','LineWidth',1)
quiver3(0,-max(ylim),0,0,2*max(ylim),0,'b','LineWidth',1)
quiver3(-max(xlim),0,0,2*max(xlim),0,0,'b','LineWidth',1)
text(0,0,max(zlim),'Z','Color','b')
text(0,max(ylim),0,'Y','Color','b')
text(max(xlim),0,0,'X','Color','b')
axis equal
view(30,30)
set(gca, 'LineWidth',2, 'XGrid','on', 'GridLineStyle','--')
.
More Answers (0)
See Also
Categories
Find more on Vector Fields 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!