MathGroup Archive 2006

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

Search the Archive

Re: using Legend package

  • To: mathgroup at
  • Subject: [mg65651] Re: [mg65607] using Legend package
  • From: "David Annetts" <davidannetts at>
  • Date: Wed, 12 Apr 2006 05:59:59 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Hi Rudy,

>  I'd like to insert legends in my graphics.
>  I'm trying to use Legend package for that, but in the help 
> browser, there are too few indications on the way tu use it 
> efficiently. 
>  So I wonder if anybody could help me by giving me a link to 
> a page which explain in detail. Or some detailed examples or anything.
>  Thank you very much for help.

Legend is a straightforward but very tedious package.  Perhaps posting some
code might inspire better solutions than below.

Some examples follow.  Feel free to modify them to get a feel as to how they
influence the plot.  For example, if you change LegendOrientation to
Vertical, what do you have to modify to get the legend sitting just to the
right of the plot?

Example 1 just puts a legend with various options under a plot


mystyle={Black, Red, Green, Blue, Cyan};
mylgd = ToString[#]& /@ Range[5];

plt = Plot[Evaluate[BesselJ[#, x]& /@ Range[5]], {x, 0, 10}, 
      LegendLabel->"Bessel FunctionJ Order",
      LegendSize\[Rule]{1.25, .25},
      LegendPosition\[Rule]{-.5, -.9}];

Example 2 is a little more complicated and uses graphics primitives to
create a legend.

pltstyle = {Thickness[.02], #}& /@  {Black, Red, Green, Blue, Cyan};
ldgstyle = {Thickness[.2], #}& /@  {Black, Red, Green, Blue, Cyan};
newlegnd = Flatten[{#, Line[{{-1, 0}, {0, 0}}]}]& /@ ldgstyle;
newtext  = ToString[#]& /@ Range[5];
newlegnd = {Transpose[{Graphics[#]& /@newlegnd, newtext}],
      LegendLabel\[Rule]StyleForm["Bessel J Ftn Order
                ", FontWeight->"Bold", FontSlant->"Oblique"],
      LegendSize\[Rule]{1.5, .25},
      LegendPosition\[Rule]{-.7, -.9}

plt = Plot[Evaluate[BesselJ[#, x]& /@ Range[5]], {x, 0, 10}, 
      plot w/ Legend", FontFamily\[Rule]"Times", FontWeight\[Rule] "Bold",
       FontSize\[Rule] 14],
ShowLegend[plt, newlegnd];



  • Prev by Date: Re: Help with functions
  • Next by Date: Re: conditions of fit parameters
  • Previous by thread: using Legend package
  • Next by thread: Re: using Legend package