set Y-Axis to descending order without changing data
63 views (last 30 days)
Show older comments
ivan timofeev
on 6 Oct 2021
Commented: Star Strider
on 12 Apr 2022
I am calling matalb from C++ using MatlabEngine.
I have a 2D array of data absCxRes and two vectors timeShift for x-axis and frq for y-axis
arma::vec frq = arma::linspace(src1.fs() / longChunk, 0, cxResMat.n_rows);
The Y-Axis starts with 6000 and goes down to 0. However, when the image is displayed, the Y-Axis values start with 0.
std::vector<matlab::data::Array> args6({
factory.createArray({timeShift.size(), 1}, timeShift.begin(), timeShift.end()),
factory.createArray({frq.size(), 1}, frq.begin(), frq.end()),
factory.createArray({ absCxRes.n_rows, absCxRes.n_cols }, absCxRes.begin(), absCxRes.end())
});
MLPtr->eval(u"figure");
MLPtr->feval(u"pcolor", args6);
MLPtr->eval(u"shading interp");
How to change the Y-Axis numbers so that they would start with 6000 and go up to 0 without flipping the matrix.
Thanks
0 Comments
Accepted Answer
Star Strider
on 6 Oct 2021
I am not certain what the code actually does.
It seems to me that there are two options —
set(gca, 'YDir','reverse')
yt = get(gca, 'YTick');
set(gca, 'YTickLabel',flip(yt))
Then, choose the result that does what you want.
x = 1:10;
y = rand(size(x));
figure
plot(x, y)
grid
title('Original')
figure
plot(x, y)
grid
set(gca, 'YDir','reverse')
figure
plot(x, y)
grid
yt = get(gca,'YTick');
set(gca, 'YTickLabel',flip(yt))
.
6 Comments
Kundan Kumar
on 12 Apr 2022
After Struggling a lot i could find this. And it really helped me. Thanks a lot.
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!