caxis does not seem to be working...

조회 수: 13 (최근 30일)
Carmen
Carmen 2020년 5월 5일
답변: Rik 2020년 5월 5일
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
Constantino Carlos Reyes-Aldasoro
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 2020년 5월 5일
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?

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

답변 (1개)

Rik
Rik 2020년 5월 5일
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])

태그

Community Treasure Hunt

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

Start Hunting!

Translated by