
create a custom colormap
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
kim chan
el 22 de Mayo de 2020
Respondida: Ameer Hamza
el 22 de Mayo de 2020
hi all,
I would like to customize a colormap with specified color for each value range (from -4 to 2, a total of 7 intervals, and assign a color for each interval):
% a three-column matrix of RGB triplets for each interval:
map = [0.4940 0.1840 0.5560
0.8500 0.3250 0.0980
0.9290 0.6940 0.1250
1 1 0
0.4660 0.6740 0.1880
0 0.75 0.75
0 0.5 0];
% here is part of my codes:
image = imshow(x);
......
caxis([-4 2])
colorbar('Ticks',[-4 -3 -2 -1 0 1 2],...
'TickLabels',{'-4','-3','-2','-1','0','1','2'})
colormap(map)
The location of the label tick is not on the boundary between two color and I don't know how to fix it. Does anyone have an idea on this question?

0 comentarios
Respuesta aceptada
Ameer Hamza
el 22 de Mayo de 2020
Because there are 6 unit-sized intervals between -4 and 2, you should use 6 colors in the map. Try this
map = [0.4940 0.1840 0.5560
0.8500 0.3250 0.0980
0.9290 0.6940 0.1250
1 1 0
0.4660 0.6740 0.1880
0 0.75 0.75];

0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Color and Styling en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!