set Y-Axis to descending order without changing data

68 visualizaciones (últimos 30 días)
ivan timofeev
ivan timofeev el 6 de Oct. de 2021
Comentada: Star Strider el 12 de Abr. de 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

Respuesta aceptada

Star Strider
Star Strider el 6 de Oct. de 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 comentarios
Kundan Kumar
Kundan Kumar el 12 de Abr. de 2022
After Struggling a lot i could find this. And it really helped me. Thanks a lot.
Star Strider
Star Strider el 12 de Abr. de 2022
My pleasure!
(A Vote for it would be appreciated!)

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by