필터 지우기
필터 지우기

Question for color set in colorbar

조회 수: 4 (최근 30일)
aurc89
aurc89 2020년 3월 30일
댓글: Ameer Hamza 2020년 3월 30일
Hello,
I plot an image using imagesc, and the colorbar is automatically set from blue (lowest value, e.g. 0) to red (highest value, e.g. 1). Is there a way to set the interval color from white (lowest value) to red (highest value) ?
Thanks

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 3월 30일
편집: Ameer Hamza 2020년 3월 30일
You can also create you custom colormap
White = [1 1 1];
Red = [1 0 0];
t = linspace(0,1,100)';
cmap = Red.*t + White.*(1-t);
colormap(cmap);
colorbar
  댓글 수: 6
aurc89
aurc89 2020년 3월 30일
Now it works! Thanks!
Ameer Hamza
Ameer Hamza 2020년 3월 30일
Glad to be of help.

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

추가 답변 (2개)

darova
darova 2020년 3월 30일
Yes, there is a way. Use colormap
cmap = hot(100);
colormap(cmap(30:end,:)) % i use only last 70 values because first 30 is too dark
colorbar
  댓글 수: 1
aurc89
aurc89 2020년 3월 30일
Thanks! But this gives the opposite (dark=minimum, white=maximum), what if I want the reversed one (white=minimum, dark=maximum) ?

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


Image Analyst
Image Analyst 2020년 3월 30일
Try this:
grayImage = imread('cameraman.tif');
white = [1 1 1];
red = [1 0 0];
imagesc(grayImage);
ramp = linspace(0, 1, 256)';
ramp = [ramp, ramp, ramp];
customColorMap = red .* ramp + white .* (1-ramp);
colormap(customColorMap);
colorbar
  댓글 수: 1
aurc89
aurc89 2020년 3월 30일
I see the image but the code gives error, I think it's due to my previous version of Matlab.
Thanks anyway! I think it works now

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

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by