Hi,
I have a set of data that is plotted, in 2D, as a bunch of points (a scatter plot). Each point also has an intensity associated with it. How can I plot the data such that the intensity is represented by shades of color?
I.e. currently I'm specifying the appearance of the points with 'ro' string, such that each point is a red dot. How do I change this to be scaled such that the most "intense" value is deep red, and the least intense values are grey?
I've seen this done before, so I know it's possible.
Thanks!

 採用された回答

Star Strider
Star Strider 2020 年 3 月 3 日

0 投票

See Vary Circle Color in the scatter documentation.

6 件のコメント

Blenndrman
Blenndrman 2020 年 3 月 3 日
This answer would help for varying color, but varying opacity on one color (the question I asked) is not answered here. I've re-asked the question. Thanks, though!
Star Strider
Star Strider 2020 年 3 月 3 日
It is not possible to set the transparency or individual markers in a scatter plot. The best you can doi is:
hs = scatter(x, y, [], c, 'filled')
hs.MarkerFaceAlpha = 0.5;
Blenndrman
Blenndrman 2020 年 3 月 3 日
"It is not possible to set the transparency or individual markers in a scatter plot"
Maybe not directly, but it's clearly possible to closely mimic the effect, much more closely than what is presented. This is what I'm looking for help with. Easyspin's "levelsplot" function does it all the time. (Download the package, set up a system, and try it: http://easyspin.org/easyspin/documentation/levelsplot.html). The problem is that their code is P-code so I can't see how they do it. They scale from red to grey. Nothing else.
Star Strider
Star Strider 2020 年 3 月 3 日
編集済み: Star Strider 2020 年 3 月 3 日
Try this (kludgy and inefficient although it seems to work):
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
c = linspace(1,10,length(x));
cm = jet(numel(x));
figure
hold on
for k = 1:numel(x)
hs = scatter(x(k),y(k));
hs.MarkerEdgeColor = cm(k,:);
hs.MarkerFaceColor = cm(k,:);
hs.MarkerFaceAlpha = abs(y(k)/max(y));
hs.MarkerEdgeAlpha = abs(y(k)/max(y));
end
hold off
EDIT —
Added: MarkerEdgeAlpha and plot figure.
Blenndrman
Blenndrman 2020 年 3 月 3 日
Thank you! I was able to manipulate this to get a one-color grayscale.
Star Strider
Star Strider 2020 年 3 月 3 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by