### MATLAB >> scatter plot legend marker color

Hi,

I seem to have come across this problem before, but have forgotten the
solution.

I have a scatterplot,

scatter(X1,Y1,50,Z1), hold on
scatter(X2,Y2,50,Z2), hold on
scatter(X3,Y3,50,Z3), hold off
legend('a','b','c')

the color of the markers in the legend are some light green color, I'd
rather have them be black.
I've looked at the legend properties, and found the Children, but I
see nothing about 'marker', 'facecolor', etc. Maybe I'm looking in
the wrong spot? (Aside: I really wish I could use something like
"grep" on matlab output).

Thanks!

### MATLAB >> scatter plot legend marker color

hMarkers = findobj(hLegend,'type','patch');
set(hMarkers, 'MarkerEdgeColor','k', 'MarkerFaceColor','k');

Yair Altman

### MATLAB >> scatter plot legend marker color

I always forget about findobj. Thanks!

```I'm adding points from different experiments to a plot and I would like to color them differently for each experiment.  The problem is that the number of experiments varies.  Therefore I need to make a color table that has n different colors, where n is the number of experiments.  I realize that I can assign a color in a plot by using, e,.g:
plot( ...,'markerfacecolor',[a b c])

and my question is how do I vary a,b,c so that I get a (rainbow) spectrum of colors.

I tried:

for i=1:n
plot( [data from experiment], markerfacecolor',[1 1 1]/i)

and this resulted in shades of gray, which is difficult to view if there are more than 3-4 experiments.
```

```On a plot with a legend, how can I get the markers in the legend to be a different size from the one in the plots that the legend is pointing to?   I want to do this since my plot markers are small due to the large amount of data, but then they don't show up very well in the legend.

Example code:
x=[1:1:10];
figure;
hplot = plot(x,x,'.k');
h_for_legend = hplot;
set(hplot,'MarkerSize',2);   % small size marker
set(h_for_legend,'MarkerSize',12);   % attempt to get larger marker for legend
legend_string = 'my data';
legend(h_for_legend,legend_string);

I was hoping that the markers on the plot (handle hplot) would be size 2, and the marker in the legend (handle h_for_legend) would be size 12 so it would be visible.  A single size 2 marker in the legend is too small.     But the datapoints in the plot inheirit the marker size that I gave the legend (12).    How can I get them to be different in the plot vs. the legend (and change other attributes as well if I want)?

Thanks very much.
```

```Hi. Does anyone know how to put separate legends to multiple scatter plots?

e.g.
x=1:10;
y=11:20;
z=-y;

hold on;
scatter(x,y,'or')
scatter(x,z,'+b')
legend('y-name','z-name')
hold off

This example incorrectly puts two legends 'y-name' and 'z-name' to one series y.

Thanks a lot.
```

```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!
```