How to show axis in 3D

조회 수: 220 (최근 30일)
Niklas Kurz
Niklas Kurz 2021년 6월 26일
댓글: Star Strider 2021년 6월 29일
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?

채택된 답변

Star Strider
Star Strider 2021년 6월 26일
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','--')
.
  댓글 수: 2
Niklas Kurz
Niklas Kurz 2021년 6월 29일
Basically I was asking for an easier way to implement those arrows that I drew inconveniently with quiver. Yor gca-manipulation also is an enhancement to better orientate in 3D-plots
Star Strider
Star Strider 2021년 6월 29일
Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by