Scatter plot markers dont show colors of the colormap

11 Ansichten (letzte 30 Tage)
Sara Loren
Sara Loren am 12 Dez. 2020
Bearbeitet: Sara Loren am 26 Jan. 2021
.
  2 Kommentare
dpb
dpb am 12 Dez. 2020
scatter doesn't know about the density of location; it just draws a marker at the location.
You'll need to use histcounts2 to bin the data in XY coordinate space and then use that count array as the color variable.
Sara Loren
Sara Loren am 13 Dez. 2020
Thanks for the response. This code worked for me.
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
sz = 10;
c = linspace(1,100,length(x));
scatter(x,y,sz,c,'filled')

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Cris LaPierre
Cris LaPierre am 12 Dez. 2020
You could try using the syntax for scatter that includes color: scatter(x,y,sz,c)
You'd have to include a color for each marker.
  2 Kommentare
dpb
dpb am 12 Dez. 2020
Yeah, but how to obtain the color that is representative of the point density...be interesting if OP would attach the data file to play with; I've not tried such a thing that can think of having done.
A search uncovered that one of the mapping toolboxen has a topographical density plotting facility with it -- that would be a great addition to add to general graphics types.
Cris LaPierre
Cris LaPierre am 13 Dez. 2020
Good points. I wonder if hist3 with a tiled view would work.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by