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!

 Risposta accettata

Star Strider
Star Strider il 3 Mar 2020

0 voti

See Vary Circle Color in the scatter documentation.

6 Commenti

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!
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;
"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 il 3 Mar 2020
Modificato: Star Strider il 3 Mar 2020
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.
Thank you! I was able to manipulate this to get a one-color grayscale.
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by