Re: Creating a Legend with ListPlot using PlotMarkers
- To: mathgroup at smc.vnet.net
- Subject: [mg84841] Re: Creating a Legend with ListPlot using PlotMarkers
- From: dh <dh at metrohm.ch>
- Date: Wed, 16 Jan 2008 22:57:35 -0500 (EST)
- References: <fmhqmn$bou$1@smc.vnet.net>
Hi Andy,
seems to be another bug of version 6.
Here is an working example using ShowLegend:
data=Table[RandomReal[]+8,{2},{6}];
plmarkers={{"\[FilledSquare]",Medium},{"\[FilledCircle]",Medium}};
plot=ListPlot[data,PlotMarkers->plmarkers,PlotStyle->Black,Axes->False,Frame->True];
ShowLegend[plot,{{{Graphics@Text@plmarkers[[1,1]],"DEEP2"},{Graphics@Text@plmarkers[[2,1]],"CFRS"}},LegendShadow->{0,0},LegendPosition->{-.8,.2},LegendSize->{0.4,0.3}}]
hope this helps, Daniel
Uayeb wrote:
> I'm trying to create a legend for a list plot of points using the
> PlotMarkers generated with the option PlotMarkers->Automatic. Seems
> the only way to do this is by creating my own set of plot markers
> which I can hand both to the ListPlot[data,PlotMarkers->myMarkers] and
> to the Legend[Table[{myMarkers[[i]],"data "<>ToString[i]},
> {i,Length[myMarkers]}]] (or similar) call. Seems that the
> Automatically generated markers should be around somewhere, similar to
> how the colors used to generate a line plot are in ColorData[1,i].
>
> Also, drawing a box around the legend via LegendShadow->{0,0} has
> unexpected results:
>
> data = Table[RandomReal[] + 8, {2}, {6}]
> plot = ListPlot[data, PlotMarkers -> Automatic, PlotStyle -> Black,
> Axes -> False, Frame -> True]
> Show[plot,
> Graphics[Legend[{{Graphics[{Inset[
> Style["\[FilledSquare]", FontSize -> 8.96], {0, 0}]}],
> "DEEP2"}, {Graphics[{Inset[
> Style["\[FilledCircle]", FontSize -> 8.96], {0, 0}]}],
> "CFRS"}}, LegendShadow -> {0, 0}, LegendPosition -> {1, 8.7}]]]
>
> This code produces a Boxed Legend, but the box expands to touch the
> top of the plot frame. Looking at the InputForm of the output gives no
> indication that this shouldn't draw correctly.
>
> Cheers,
> Andy
>