Heatmap - how to get the plotted colors

11 次查看(过去 30 天)
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);

回答(2 个)

J Chen
J Chen 2021-9-3
camp = colormap
https://www.mathworks.com/help/matlab/ref/colormap.html
  1 个评论
Nils Liebe
Nils Liebe 2021-9-5
编辑:Nils Liebe 2021-9-5
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). :(

请先登录,再进行评论。


darova
darova 2021-9-5
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

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by