From: Jens-Peer Kuska on
Hi,

ListLinePlot[{a, b},
PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}, Epilog ->
Legend[{{RGBColor[1, 0, 0],
Style["a", "Section"]}, {RGBColor[0, 0, 1],
Style["b", "Section"]}}, LegendPosition -> {7, 0.8},
LegendSize -> {2, 1}, LegendTextSpace -> 0.5] , PlotRange -> All ]

??

it is so clumsy as before ...
Regards
Jens

Nasser Abbasi wrote:
> Hello;
>
> I am drawing few lists in one plot using ListLinePlot.
> PlotLegend does not work with ListLinePlot. Any idea how can one add legend
> to listLinePlot?
>
> Needs["PlotLegends`"];
> a = Table[RandomReal[], {10}];
> b = Table[RandomReal[], {10}];
> ListLinePlot[{a, b}] (*OK*)
> ListLinePlot[{a, b}, PlotLegend -> {"a", "b"}] (*This is what I'd like to
> do*)
>
> thanks
> Nasser
>
>

From: Robert Pigeon on
Hello Nasser,
I had the same problem with the Legend package, but thanks to some people
here in Mathgroup I could make some sense out of it. So, here is an example
of a simple ListLinePlot with a Legend, nothing sophisticated but just a
start. I think it is the kind of example that should be in the
documentation, but, that is another story! By the way, it works with other
plot command.

___________________________________________________________

Needs["PlotLegends`"]

a = Table[{i, i^2}, {i, 1, 20}];
b = Table[{i, i^3}, {i, 1, 20}];


ShowLegend[
ListLinePlot[{a, b},
PlotStyle -> {Directive[Red], Directive[Blue, Dashed]},
PlotLabel -> "Test",
Frame -> True,
FrameLabel -> {{fonction, func}, {x,(*nothing on top*)}},
GridLines -> {Automatic, Automatic},
GridLinesStyle -> {Directive[Black], Directive[Green, Dashed]},
Background -> LightYellow,
ImageSize -> 600,
BaseStyle -> {FontSize -> 12, FontWeight -> "Bold"}],

(*Here is the legend *)

{
{{Graphics[{Red, Line[{{0, 0}, {5, 0}}]}],
"Line a"}, {Graphics[{Directive[Blue, Dashed],
Line[{{0, 0}, {5, 0}}]}], "Line b"}},
LegendSize -> {0.7, 0.2},
LegendPosition -> {0, -0.85},
BaseStyle -> {FontSize -> 12, FontWeight -> "Bold"}
}

]

__________________________________________________________________


As I said, it is a basic example and it is laid out without trying to get
the best!

Hope this help.

Robert

Robert Pigeon


-----Original Message-----
From: Nasser Abbasi [mailto:nma(a)12000.org]
Sent: May-23-07 05:15
Subject: How to add legend to ListLinePlot?

Hello;

I am drawing few lists in one plot using ListLinePlot.
PlotLegend does not work with ListLinePlot. Any idea how can one add legend

to listLinePlot?

Needs["PlotLegends`"];
a = Table[RandomReal[], {10}];
b = Table[RandomReal[], {10}];
ListLinePlot[{a, b}] (*OK*)
ListLinePlot[{a, b}, PlotLegend -> {"a", "b"}] (*This is what I'd like to
do*)

thanks
Nasser