Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Legend for DateListPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100030] Re: Legend for DateListPlot
  • From: Peter Breitfeld <phbrf at t-online.de>
  • Date: Fri, 22 May 2009 01:44:29 -0400 (EDT)
  • References: <gv2jsc$9cb$1@smc.vnet.net>

greg.mcavoy at gmail.com wrote:

> I would like to add a PlotLegend to a time series plot like the one
> below.
> DateListPlot[{Tooltip[FinancialData["MSFT", "2006"],
>    "Microsoft Corporation"],
>   Tooltip[FinancialData["SNE", "2006"], "Sony Corporation"],
>   Tooltip[FinancialData["AKAM", "2006"], "Akamai Technologies Inc"]},
>  Joined -> True]
>
> I tried using the PlotLegends package, but it doesn't appear to work
> with DateListPlot
> (code below)
> Needs["PlotLegends`"]
>
> DateListPlot[{FinancialData["MSFT", "2006"],
>   FinancialData["SNE", "2006"], FinancialData["AKAM", "2006"]},
>  Joined -> True,
>  PlotLegend -> { "Microsoft Corporation", "Sony Corporation",
>    "Akamai Technologies Inc"}]
>
> Is there a work around to this problem or something wrong with my
> code?  I want to export the graph to for use in a latex document so
> Tooltip is not a useful option.
>

DateListPlot seems not to understand PlotLegend, but ShowLegend works e.g.

Needs["PlotLegends`"]

ShowLegend[
 DateListPlot[{FinancialData["MSFT", "2006"], 
   FinancialData["SNE", "2006"], FinancialData["AKAM", "2006"]}, 
  Joined -> True,
  PlotStyle -> {Red, Green, 
    Blue}], {{{Graphics[{Red, Thick, Line[{{0, 0}, {1, 0}}]}], 
    "Microsoft Corporation"},
   {Graphics[{Green, Thick, Line[{{0, 0}, {1, 0}}]}], 
    "Sony Corporation"},
   {Graphics[{Blue, Thick, Line[{{0, 0}, {1, 0}}]}], 
    "Akamai Technologies Inc"}},
  LegendPosition -> {-1, -1.15},
  LegendSize -> {1, 0.5},
  LegendTextSpace -> 3}
 ]

-- 
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de


  • Prev by Date: Re: 100,000 posts!
  • Next by Date: Re: Rotating a list of 3D point coordinates in one shot
  • Previous by thread: Re: Legend for DateListPlot
  • Next by thread: Mathematica in Research and Education - Liege and Delft