Problem with adjusting custom colormap and colorbar

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 3 Ago 2020
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

Più risposte (0)

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by