Problem with adjusting custom colormap and colorbar

5 visualizaciones (últimos 30 días)
BN
BN el 3 de Ag. de 2020
Comentada: Walter Roberson el 4 de Ag. de 2020
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 3 de Ag. de 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

Más respuestas (0)

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by