How to keep yticklabels intact after reversing the Y-axis

2 次查看(过去 30 天)
I reversed y-direction in a chart, but I would like my yticklabels stay same as were, ie. 80 at the top and 0 at bottom. How do I solve it?
I tried to define them manually but to no avail
yticklabels([0:10:80])
set(gca,'ydir','reverse')

采纳的回答

Star Strider
Star Strider 2021-12-5
Just change the labels —
x = linspace(0, 100);
y = [20:20:80].'*exp(-(x-50).^2/75);
figure
plot(x, y)
grid
title('Original')
figure
plot(x, y)
grid
Ax = gca;
yt = Ax.YTick;
Ax.YDir = 'reverse';
Ax.YTickLabel = string(flip(yt));
title('Flipped Y-Axis With Retained Original Y-Axis Labels')
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by