From: jrenfree on
Hi all,

I'm making a bubble plot using the scatter function in Matlab to show
the density of fish schools in a map of lat and long coordinates.
That is, the more dense the fish school, the larger the circle on the
scatter plot.

I can't figure out how to get a legend on the graph that shows what
the different sized circles represent. When I add the legend, it has
all the circles as being the same size.

Any ideas?

Thanks!
From: us on
jrenfree <jrenfree(a)gmail.com> wrote in message <13608143-1584-46e6-bd12-81d198808beb(a)j36g2000prj.googlegroups.com>...
> Hi all,
>
> I'm making a bubble plot using the scatter function in Matlab to show
> the density of fish schools in a map of lat and long coordinates.
> That is, the more dense the fish school, the larger the circle on the
> scatter plot.
>
> I can't figure out how to get a legend on the graph that shows what
> the different sized circles represent. When I add the legend, it has
> all the circles as being the same size.
>
> Any ideas?
>
> Thanks!

one of the (rather tedious) solutions

x=1:10;
y=rand(size(x));
s=linspace(10,200,numel(x));
sh=scatter(x,y,s,jet(10),'filled');
% now...
sc=get(sh,'children');
ss=get(sc,'markersize');
cm=get(sc,'cdata');
lh=legend(sc);
lc=findall(lh,'type','patch');
set(lc,{'markersize'},ss,{'cdata'},cm);

us