How do I add scale markers to the legend, to indicate values for the sizes of points in a scatter plot?

10 views (last 30 days)
Hello,
I have the scatter plot showing a 4 dimentional data set. It was generated using:
scatter(dimentionA,dimentionB,dimentionC,dimentionD,'filled','MarkerEdgeColor','w')
The x-y axis, cover 2 dimentions, the colourbar covers the 3rd and the point sizes cover the 4th dimention.
How do I add a point size/scale indicator to the legend, in order to lebel the 4th (point sizes) dimention?
Thanks!

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 25 Sep 2020
I'd do something like:
sz = 12:2:24; % your suitable selection for your dimentionC-mapping-to-size
y4size = linspace(45,110,numel(sz));
x4size = 15*ones(size(y4size));
scatter(x4size,y4size,sz,'k','filled')
for it = 1:numel(sz)
text(15.5,y4size(it),sprintf('%3.1f',Cval(it)))
end
You'll have to fill in your suitable range of values of your dimentionC-data that you want to display the size of the scatter-points for, and also change the 12:2:24 to something suitable. But this should give you something to start with.
HTH
  6 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 26 Sep 2020
My pleasure.
The file exchange is GREAT, I've gotten so much useful stuff there that I've no idea how much time and effort I've saved through the years. My first step when solving a problem is to have a look there for a solution...

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!