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

37 次查看(过去 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')

标签

Community Treasure Hunt

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

Start Hunting!

Translated by