![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/280626/image.png)
Question for color set in colorbar
4 ビュー (過去 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
0 件のコメント
採用された回答
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/280626/image.png)
6 件のコメント
その他の回答 (2 件)
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
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/280637/image.png)
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!