How to flip the data upside down without flipping the axes?

x = [1 2 3];
y= [6 13 11];
plot(x,y)
set(gca,'Ydir','reverse')
I tried this code but it flips the y axis. I want to keep both axis the same.

댓글 수: 4

Looking for: A picture to understand the question?
dpb
dpb 2021년 1월 18일
편집: dpb 2021년 1월 18일
Indeed.
One could use
plot(x,-y)
but will, of course put them below the y==0 axis.
Alternatively, there's
plot(x,y)
hold on
plot(x,19-y,'r-*')
Kofial
Kofial 2021년 1월 18일
편집: Kofial 2021년 1월 18일
There is no picture, only a line like the one provided.
This plot(x,-y) doesn't work plot(x,-y) because it converts the y axis in negative values.
This second option either. I don't want to do any changes to the axis, only flip the data.
Remove the -y from the second; that was a figment of the copy/paste...it's the same idea that Star-S shows.

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

 채택된 답변

Star Strider
Star Strider 2021년 1월 18일
I am not certain what result you want.
Try this:
x = [1 2 3];
y = [6 13 11];
figure
plot(x,max(y)-y+min(y))
.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2021년 1월 18일

댓글:

dpb
2021년 1월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by