MathGroup Archive 2009

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

Search the Archive

Re: Legend for DateListPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100046] Re: Legend for DateListPlot
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Fri, 22 May 2009 01:47:26 -0400 (EDT)
  • References: <gv2jsc$9cb$1@smc.vnet.net>

PlotLegend works only for Plot, ListPlot and ListLinePlot. For all
other plots use ShowLegend like here:

<< PlotLegends`

ShowLegend[
 DateListPlot[{Tooltip[FinancialData["MSFT", "2006"],
    "Microsoft Corporation"],
   Tooltip[FinancialData["SNE", "2006"], "Sony Corporation"],
   Tooltip[FinancialData["AKAM", "2006"], "Akamai Technologies Inc"]},
   Joined -> True,
  PlotStyle -> {Red, Green,
    Blue}], {{{Graphics[{Red, Line[{{0, 0}, {1, 0}}]}],
    "MSFT"}, {Graphics[{Green, Line[{{0, 0}, {1, 0}}]}],
    "SNE"}, {Graphics[{Blue, Line[{{0, 0}, {1, 0}}]}], "AKAM"}},
  LegendSize -> 0.5, LegendShadow -> None, LegendLabel -> "Company",
  LegendPosition -> {0.8, 0.0}}]


Cheers -- Sjoerd

On May 21, 6:04 am, greg.mca... 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.



  • Prev by Date: Re: Basic question about Mathematica Interface
  • Next by Date: Re: 100,000 posts!
  • Previous by thread: Re: Legend for DateListPlot
  • Next by thread: Re: Legend for DateListPlot