Heatmap - how to get the plotted colors

7 visualizzazioni (ultimi 30 giorni)
Nils Liebe
Nils Liebe il 3 Set 2021
Commentato: Nils Liebe il 5 Set 2021
Dear all,
I would like to get the rgb-color code of a data set i am plotting in a heatmap. Does anyone know where they are stored or how to extract them?
%Exp.
Data=[0.216745778875956
0.0122005059399983
0.0162673412533310
0.00149830774701733
0.263389055948955
0.342338724357287
0.0955767041221151
0.119981642250681
0.0606266369191968
0.759691756727176
0.514382973045806
0.668104140446562
0.720311719592812
0.671178482390491
0.278785037951106
0.476509405546337
0.409639773389851
0.582438199698988
0.567789956119946
0.281777114781149
0.674368366676059
0.188936792339474
0.746659486291274
0.827451886871509
0.708089195819381
0.345204905187858
0.492727562626227
0.453467008650955];
fig=heatmap(Data,'Colormap',jet);

Risposte (2)

J Chen
J Chen il 3 Set 2021
camp = colormap
https://www.mathworks.com/help/matlab/ref/colormap.html
  1 Commento
Nils Liebe
Nils Liebe il 5 Set 2021
Modificato: Nils Liebe il 5 Set 2021
Thanks for your answer.
I already tried colormap(); The problem is that you get all 256 values auf the jet-colormap. I only want the rgb-values of my 28 data points (or the position within the colormap). :(

Accedi per commentare.


darova
darova il 5 Set 2021
Just scale values
%Exp.
Data=[0.216745778875956
0.0122005059399983
0.0162673412533310
0.00149830774701733
0.263389055948955
0.342338724357287
0.0955767041221151
0.119981642250681
0.0606266369191968
0.759691756727176
0.514382973045806
0.668104140446562
0.720311719592812
0.671178482390491
0.278785037951106
0.476509405546337
0.409639773389851
0.582438199698988
0.567789956119946
0.281777114781149
0.674368366676059
0.188936792339474
0.746659486291274
0.827451886871509
0.708089195819381
0.345204905187858
0.492727562626227
0.453467008650955];
n = 100; % number of colors
ind = round(Data*n)+1; % indices of colors (scale)
cm = jet(n); % create colormap
cm(ind,:) % show colors RGB
ans = 28×3
0 0.4000 1.0000 0 0 0.5600 0 0 0.6000 0 0 0.5200 0 0.5600 1.0000 0 0.8800 1.0000 0 0 0.9200 0 0 1.0000 0 0 0.7600 1.0000 0.4400 0

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Tag

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by