caxis does not seem to be working...

13 visualizaciones (últimos 30 días)
Carmen
Carmen el 5 de Mayo de 2020
Respondida: Rik el 5 de Mayo de 2020
Hi,
Thanks in advance for your help.
I am trying to change the limits of my colorbar from 0 to 450. I have tried caxis, and changing CLim, ibut neither works. I have tried it with both 2018 and 2019 Matlab (and the webbased one) on 2 different computers, so it seems like I am doing someting inherintly wrong.
testarray=[0 90 180 270 360 450];
image(testarray);
cb=colorbar;
caxis([0 450])
Even when I use the example on the image page, it does not work like they show.
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
image(C)
colorbar
  2 comentarios
Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro el 5 de Mayo de 2020
Hello Carmen
I suggest that you do not use "image" but "imagesc" as the command imagesc scales (that is the sc at the end) the values that you use, if you use it the result is what you would expect.
>> imagesc(testarray);
Hope this solves your question. If it does, please accept the answer, if not, do let me know.
Carmen
Carmen el 5 de Mayo de 2020
This solves it! Thank you so much. I do not see an option to accept your answer, do you have to submit is as an answer rather than a comment?

Iniciar sesión para comentar.

Respuestas (1)

Rik
Rik el 5 de Mayo de 2020
You can use image, but you do need to make sure you are scaling your colors, instead of using the direct mapping. If you look at the image documentation you can see an explanation.
It is of course also possible to set the CDataMapping property of your image object after you've created it.
testarray=[0 90 180 270 360 450];
image(testarray,'CDataMapping','scaled');
cb=colorbar;
caxis([0 450])

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by