How to create a colormap attributing specific colour to each element?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Cassio Lima
am 26 Jan. 2019
Kommentiert: Cassio Lima
am 28 Jan. 2019
Hi everyone!
I have an array A,
A = [ 1 2 3 4
2 2 3 1
1 1 4 2];
I want to create a colormap but each element needs to be colored in a specific colour, for example, 1 is blue, 2 is black, 3 is green and 4 is yellow.
Thanks
Akzeptierte Antwort
Matt Gaidica
am 26 Jan. 2019
Given these data, I would do this.
A = [ 1 2 3 4
2 2 3 1
1 1 4 2];
cmap = jet(max(A(:)));
figure;
imagesc(A);
colormap(cmap);
colorbar;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Orange 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!