
create a custom colormap
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
kim chan
am 22 Mai 2020
Beantwortet: Ameer Hamza
am 22 Mai 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 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 22 Mai 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Color and Styling finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!