plotting values in in reverse order

조회 수: 125 (최근 30일)
Ester
Ester 2015년 12월 17일
댓글: Star Strider 2022년 8월 29일
I would like to plot my X-axis values in the reverse direction. I mean if they are A= [ 0 1 2 3 4 5 ] Then instead of plotting them from 0 to 5 I would like to plot them from 5 to 0. I did plot(fliplr(x),y);set(gca,'xdir','reverse') and the labels of the x axis are reversed but the data is still plotted in the same direction. How can I reverse the direction in which the data is plotted?
THANKS! (o:
Ester

답변 (1개)

Star Strider
Star Strider 2015년 12월 17일
Set the x-axis direction 'XDir' to 'reverse':
Example:
x = 0:5;
y = 3 + 2*x;
figure(1)
subplot(2,1,1)
plot(x, y)
grid
subplot(2,1,2)
plot(x,y)
set(gca, 'XDir','reverse')
grid
  댓글 수: 5
Bruno Luong
Bruno Luong 2022년 8월 29일
편집: Bruno Luong 2022년 8월 29일
@Ana Gonçalves 'XDir' is an axes property not figure
Star Strider
Star Strider 2022년 8월 29일
Following up on that —
x = 0:5;
y = 3 + 2*x;
figure(1)
subplot(2,1,1)
plot(x, y)
grid
subplot(2,1,2)
plot(x,y)
grid
Kids = figure(1).Children;
Kids(1).XDir = 'reverse';
NOTE — In this instance (using subplot) the second subplot is the first axes object.
.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by