How do I get the a/y axes labels to show correctly?

조회 수: 4 (최근 30일)
W. Jeremy Morrison
W. Jeremy Morrison 2023년 4월 29일
댓글: W. Jeremy Morrison 2023년 4월 29일
I'm coding a project and want to output 4 plots together in a tiled layout. However two of the plots (the bottom two) only show 1 axis label and not the other. How do I fix this?
Attached below is the code for a tiled layout and the resulting figure:
% ECLIPJ2000
figure(11)
tcl = tiledlayout(2,2);
nexttile
plot3(state_f1_storage(1,:), state_f1_storage(2,:), state_f1_storage(3,:))
hold on
plot3(state_f1_storage(1,1),state_f1_storage(2,1),state_f1_storage(3,1), "og", "LineWidth", 2)
plot3(state_f1_storage(1,end),state_f1_storage(2,end),state_f1_storage(3,end), "rx", "LineWidth", 2)
ellipsoid(0,0,0,6.25,6.25,6.25)
hold off
xlabel('x (km)')
ylabel('y (km)')
zlabel('z (km)')
axis equal
grid on
nexttile
plot3(state_f1_storage(1,:), state_f1_storage(2,:), state_f1_storage(3,:))
hold on
plot3(state_f1_storage(1,1),state_f1_storage(2,1),state_f1_storage(3,1), "og", "LineWidth", 2)
plot3(state_f1_storage(1,end),state_f1_storage(2,end),state_f1_storage(3,end), "rx", "LineWidth", 2)
ellipsoid(0,0,0,6.25,6.25,6.25)
hold off
xlabel('x (km)')
ylabel('y (km)')
axis equal
grid on
view(0,90)
nexttile
plot3(state_f1_storage(1,:), state_f1_storage(2,:), state_f1_storage(3,:))
hold on
plot3(state_f1_storage(1,1),state_f1_storage(2,1),state_f1_storage(3,1), "og", "LineWidth", 2)
plot3(state_f1_storage(1,end),state_f1_storage(2,end),state_f1_storage(3,end), "rx", "LineWidth", 2)
ellipsoid(0,0,0,6.25,6.25,6.25)
hold off
xlabel('x (km)')
ylabel('z (km)')
axis equal
grid on
view(90,0)
nexttile
plot3(state_f1_storage(1,:), state_f1_storage(2,:), state_f1_storage(3,:))
hold on
plot3(state_f1_storage(1,1),state_f1_storage(2,1),state_f1_storage(3,1), "og", "LineWidth", 2)
plot3(state_f1_storage(1,end),state_f1_storage(2,end),state_f1_storage(3,end), "rx", "LineWidth", 2)
ellipsoid(0,0,0,6.25,6.25,6.25)
hold off
xlabel('y (km)')
ylabel('z (km)')
axis equal
grid on
view(0,0)
title(tcl,'ECLIPJ2000 Frame')

채택된 답변

Image Analyst
Image Analyst 2023년 4월 29일
You're not setting all the labels for those plots, specifically, you're not setting the vertical axis label for the bottom two plots. Try setting all 3 labels regardless of the view, and the view should show it correctly. We can't run your code because you didn't included the state_f1_storage variable.
% ECLIPJ2000
figure(11)
tcl = tiledlayout(2,2);
nexttile
plot3(state_f1_storage(1,:), state_f1_storage(2,:), state_f1_storage(3,:))
hold on
plot3(state_f1_storage(1,1),state_f1_storage(2,1),state_f1_storage(3,1), "og", "LineWidth", 2)
plot3(state_f1_storage(1,end),state_f1_storage(2,end),state_f1_storage(3,end), "rx", "LineWidth", 2)
ellipsoid(0,0,0,6.25,6.25,6.25)
hold off
xlabel('x (km)')
ylabel('y (km)')
zlabel('z (km)')
axis equal
grid on
nexttile
plot3(state_f1_storage(1,:), state_f1_storage(2,:), state_f1_storage(3,:))
hold on
plot3(state_f1_storage(1,1),state_f1_storage(2,1),state_f1_storage(3,1), "og", "LineWidth", 2)
plot3(state_f1_storage(1,end),state_f1_storage(2,end),state_f1_storage(3,end), "rx", "LineWidth", 2)
ellipsoid(0,0,0,6.25,6.25,6.25)
hold off
xlabel('x (km)')
ylabel('y (km)')
zlabel('z (km)')
axis equal
grid on
view(0,90)
nexttile
plot3(state_f1_storage(1,:), state_f1_storage(2,:), state_f1_storage(3,:))
hold on
plot3(state_f1_storage(1,1),state_f1_storage(2,1),state_f1_storage(3,1), "og", "LineWidth", 2)
plot3(state_f1_storage(1,end),state_f1_storage(2,end),state_f1_storage(3,end), "rx", "LineWidth", 2)
ellipsoid(0,0,0,6.25,6.25,6.25)
hold off
xlabel('x (km)')
ylabel('y (km)')
zlabel('z (km)')
axis equal
grid on
view(90,0)
nexttile
plot3(state_f1_storage(1,:), state_f1_storage(2,:), state_f1_storage(3,:))
hold on
plot3(state_f1_storage(1,1),state_f1_storage(2,1),state_f1_storage(3,1), "og", "LineWidth", 2)
plot3(state_f1_storage(1,end),state_f1_storage(2,end),state_f1_storage(3,end), "rx", "LineWidth", 2)
ellipsoid(0,0,0,6.25,6.25,6.25)
hold off
xlabel('x (km)')
ylabel('y (km)')
zlabel('z (km)')
axis equal
grid on
view(0,0)
title(tcl,'ECLIPJ2000 Frame')
  댓글 수: 1
W. Jeremy Morrison
W. Jeremy Morrison 2023년 4월 29일
Genius!!! And that makes a lot of sense because it is still a 3D plot even if I view it in a 2D plane view, which I didn't realize.
Thank you so much! It works perfectly now.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axes Appearance에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by