Problem with adjusting custom colormap and colorbar

4 ビュー (過去 30 日間)
BN
BN 2020 年 8 月 3 日
コメント済み: Walter Roberson 2020 年 8 月 4 日
Hello everyone
How to adjust a color bar in this way?
lower than 0.05 = white
0.05 ~ 0.1 = red
0.1 ~ 0.2 = yellow
0.2 ~ 0.3 = green
0.4 ~0.5 = blue
greater than 0.5 = black
Here is my try:
mycolormap = [1 1 1; 1 0 0; 1 1 0; 0 1 0; 0 0 1;0 0 0 ];
colormap (mycolormap)
caxis([0.05, 0.5])
c=colorbar('XTickLabel',{'0.05','0.1','0.2','0.3','0.4','0.5'});
But unfortunately here is my color bar:
which the colors not correctly showing and also color bar tick labels are not consonant.
Thanks

採用された回答

Walter Roberson
Walter Roberson 2020 年 8 月 3 日
The colormap process is uniform mapping. All bars are the same size. However you can assign the same color to multiple bars.
white
red
yellow
yellow
green
green
blue
blue
black
also note that for mapping purposes, you cannot say "less than" and assign a color to that condition. You need to assign a slot of equal size to the other slots. This can require you to expand your caxis
  2 件のコメント
BN
BN 2020 年 8 月 3 日
Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by