MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

listplot and legend (again)


Hello, Arek

When Mathematica automatically chooses colors for plotting in ListPLot
or ListLinePlot, it takes colors defined in ColorData[1], in the order
defined there. That means, your first line (or set of points) is plotted
in ColorData[1,1], the second in ColorData[1,2], and so on. I don't
think that this is mentioned anywhere in the Help system.

Once you know this, it is straight foreward to make your own legends,
with not need for the PlotLegend package.

Here are two examples; the first one plots the legend as part of the
Plot itself (as Epilog), the second shows the legend as a separate
element next to the Plot.

data = Table[RandomReal[], {4}, {5}];

legend = Framed@
   Column[Table[
     Style["data " <> ToString[i], ColorData[1, i], Bold, "Graphics",
      15], {i, Length[data]}]];

(* Example 1 *)
ListLinePlot[data, ImageSize -> 300,
 Epilog -> Inset[legend, {.5, .5}]]

(* Example 2 *)
Row[{ListLinePlot[data, ImageSize -> 300], legend}]

Hope that helps,
Thomas


On 8/14/07, Arkadiusz.Ma... at gmail.com <Arkadiusz.Ma... at gmail.com> wrote:


Hi,

I know that there has been at least one post on this topic but I still
can't draw legend inside ListPlot.

When i plot several curves, colors for them  are chosen automaticaly
by Mathematica. How can I plot a legend for them?

May I ask for an example, please? Why quite good solution existed in
MultipleListPlot in Mathv5.2 just vanished????

Arek


  • Prev by Date: Re: Manipulate with Wrapping SetterBars
  • Next by Date: Re: Manipulate with Wrapping SetterBars
  • Previous by thread: Re: Re: Version 6 "Mathematica Book" - updated
  • Next by thread: Re: Version 6 "Mathematica Book" - updated and expanded