Re: using Legend package
- To: mathgroup at smc.vnet.net
- Subject: [mg65651] Re: [mg65607] using Legend package
- From: "David Annetts" <davidannetts at aapt.net.au>
- Date: Wed, 12 Apr 2006 05:59:59 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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 Needs["Graphics`Legend`"] mystyle={Black, Red, Green, Blue, Cyan}; mylgd = ToString[#]& /@ Range[5]; plt = Plot[Evaluate[BesselJ[#, x]& /@ Range[5]], {x, 0, 10}, PlotStyle\[Rule]mystyle, PlotLegend\[Rule]mylgd, LegendLabel->"Bessel FunctionJ Order", LegendOrientation\[Rule]Horizontal, LegendShadow\[Rule]None, 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"], LegendOrientation\[Rule]Horizontal, LegendShadow\[Rule].001, LegendSize\[Rule]{1.5, .25}, LegendPosition\[Rule]{-.7, -.9} }; plt = Plot[Evaluate[BesselJ[#, x]& /@ Range[5]], {x, 0, 10}, PlotStyle\[Rule]newstyle, PlotLabel\[Rule]StyleForm["Example plot w/ Legend", FontFamily\[Rule]"Times", FontWeight\[Rule] "Bold", FontSize\[Rule] 14], DisplayFunction\[Rule]Identity]; ShowLegend[plt, newlegnd]; Regards, Dave.