How do I retrieve the RGB data of a scatter plot from the CData values(a 1D vector corresponding to the array lengths X and Y) ?
15 ビュー (過去 30 日間)
古いコメントを表示
Sri Vutukuri
2017 年 7 月 20 日
回答済み: Walter Roberson
2017 年 7 月 25 日
I have a scatter plot with x and y vector's as my data. I have colored using another 1D vector z which has the same number of rows as x and y. Now I would like to get the RGB values of the corresponding colors from the CData scalar values.
0 件のコメント
採用された回答
Sangeetha Jayaprakash
2017 年 7 月 24 日
You can obtain the indices based on the colormap and the Z vector applied to the CData property. Then you can get the corresponding RGB values using the "ind2rgb" function as follows:
h = scatter(x,y);
h.CData = z;
Cdata = h.CData;
cmap = colormap;
% make it into a index image.
cmin = min(Cdata(:));
cmax = max(Cdata(:));
m = length(cmap);
index = fix((Cdata-cmin)/(cmax-cmin)*m)+1; %A
% Then to RGB
RGB = ind2rgb(index,cmap)
For information on the "ind2rgb" function, refer this link:
その他の回答 (1 件)
Walter Roberson
2017 年 7 月 25 日
See the file exchange contribution freezeColors which knows how to do the calculations to convert relative value to rgb
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!