MathGroup Archive 2007

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

Search the Archive

Re: listplot and legend (again)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80402] Re: listplot and legend (again)
  • From: thomas <thomas.muench at gmail.com>
  • Date: Tue, 21 Aug 2007 05:06:49 -0400 (EDT)
  • References: <f9s462$amn$1@smc.vnet.net>

On Aug 14, 1:37 pm, 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 drawlegendinside ListPlot.
>
> When i plot several curves, colors for them  are chosen automaticaly
> by Mathematica. How can I plot alegendfor them?
>
> May I ask for an example, please? Why quite good solution existed in
> MultipleListPlot in Mathv5.2 just vanished????
>
> Arek

Hello, Arek,

When Mathematica 6 assigns plotcolors automatically in ListPlot (or
ListLinePlot) it uses the colors defined in ColorData[1]. Therefore,
the first set of data will be plotted in color ColorData[1,1], the
second in colorData[1,2] and so on. (I don't think that that is
mentioned anywhere in the Help system)

Once you know this, it is quite straigtforeward to make a legend, even
without the use of the PlotLegend package.

Here are two examples. Example 1 prints the legend as part of the
image (as Epilog), Ex. 2 prints it as separate element

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, Epilog -> Inset[legend, {.5, .5}],
 ImageSize -> 300]

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

Hope that helps,
Thomas



  • Prev by Date: Re: Mathematica 6.0 bug in computing MathieuC
  • Next by Date: lower diagonal matrix
  • Previous by thread: Re: listplot and legend (again)
  • Next by thread: Mesh->Full, Joined->True