Switch the x axis direction where positive values are on the left side of the y axis

조회 수: 18 (최근 30일)
Hey guys,
I'm working on moment of inertia calculations and have a graph that plots the cross-section in question but I want my x axis to point positively to the left, not right as it is defaulted. How can I do this?
Note: I've tried set(gca, 'ydir', 'reverse') and similiar. No luck though.
Some of my code:
rt = [1/16 3/32; 33/16 3/32]; % center locations of top stringers
z = [0 1/8 1/8 0 0; 0 4.25 4.25 0 0; 4.125 4.25 4.25 4.125 4.125;0 4.25 4.25 0 0;...
-1/16+rt(1,1) 1/16+rt(1) 1/16+rt(1,1) -1/16+rt(1,1) -1/16+rt(1,1);...
-1/16+rt(2,1) 1/16+rt(2,1) 1/16+rt(2,1) -1/16+rt(2,1) -1/16+rt(2,1)];
y = [0 0 -1.5 -1.5 0; 0 0 1/32 1/32 0; 0 0 -0.75 -0.75 0; -1.5 -0.75 -25/32 -49/32 -1.5;...
-2/32+rt(1,2) -2/32+rt(1,2) 3/32+rt(1,2) 3/32+rt(1,2) -2/32+rt(1,2);...
-2/32+rt(2,2) -2/32+rt(2,2) 3/32+rt(2,2) 3/32+rt(2,2) -2/32+rt(2,2)];
% Spar Large, Skin Top, Spar Small, Skin Bottom, Stringer 1, Stringer 2
% Important Part
set(gcf, 'Position', [100, 100, 1000, 400]); % Sizes the window
plot(z(1,:),y(1,:),z(2,:),y(2,:),z(3,:),y(3,:),z(4,:),y(4,:),z(5,:),y(5,:)); % Graphs all parts
fill(z(1,:),y(1,:),'b',z(2,:),y(2,:),'r',z(3,:),y(3,:),'g',z(4,:),y(4,:),'r',z(5,:),y(5,:),'black',z(6,:),y(6,:),'black'); % fills components
axis([-0.25 4.5 -2 0.5]); % Sets window limits

답변 (1개)

Daniel M
Daniel M 2019년 11월 6일
figure
plot(1:10)
set(gca,'XDir','reverse')
  댓글 수: 1
Kristopher Stewart
Kristopher Stewart 2019년 11월 6일
i swear I tried that.. lol But it worked. I think I had the set(... before the plot command.
Thank you,
kris

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

카테고리

Help CenterFile Exchange에서 Data Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by