Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: PlotLegend-> and DateListPlot[]...incompatible or broken?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110797] Re: PlotLegend-> and DateListPlot[]...incompatible or broken?
  • From: Darren Glosemeyer <darreng at wolfram.com>
  • Date: Wed, 7 Jul 2010 07:41:35 -0400 (EDT)

divisor wrote:
> Hello MathGroup:
>
> I have this exceeding simple test case from the supplied Documentation
> Center (I added PlotLegend):
>
> Needs["PlotLegends`"]
>
> data1 = {{{2006, 10, 1}, 10}, {{2006, 10, 15}, 12}, {{2006, 10, 30},
> 15}, {{2006, 11, 20}, 20}};
> data2 = {{{2006, 10, 5}, 15}, {{2006, 10, 20}, 8}, {{2006, 11, 10},
> 5}, {{2006, 11, 15}, 1}};
>
> DateListPlot[{data1, data2}
>  , PlotLegend -> {"sine", "cosine"}
>  , Joined -> True]
>
> It burps out lots of error messages (mostly about PadRight and Table)
> and does not print the legend.
>
> This simple example works with ListPlot[] and other plotting
> functions. Any help on this is greatly appreciated.
>
> $Version=7.0 for Microsoft Windows (64-bit) (February 18, 2009)
>
> Regards..
>
> Roger Williams
> Franklin Laboratory
>
>   

The problem is that the PlotLegends code in version 7 is not prepared to 
handle coordinates that are not numbers. This is fixed in the version 
currently under development. As a workaround in version 7, you can 
convert the date coordinates to absolute times as in the following.

Needs["PlotLegends`"]
data1 = {{{2006, 10, 1}, 10}, {{2006, 10, 15}, 12}, {{2006, 10, 30},
    15}, {{2006, 11, 20}, 20}};
data2 = {{{2006, 10, 5}, 15}, {{2006, 10, 20}, 8}, {{2006, 11, 10},
    5}, {{2006, 11, 15}, 1}};
data1[[All, 1]] = Map[AbsoluteTime, data1[[All, 1]]];
data2[[All, 1]] = Map[AbsoluteTime, data2[[All, 1]]];
DateListPlot[{data1, data2}, PlotLegend -> {"sine", "cosine"},
 Joined -> True]

Darren Glosemeyer
Wolfram Research


  • Prev by Date: Re: PlotLegend-> and DateListPlot[]...incompatible or broken?
  • Next by Date: Re: The side-effects of mixing TraditionalForm inside expressions.
  • Previous by thread: Re: PlotLegend-> and DateListPlot[]...incompatible or broken?
  • Next by thread: Copying and Pasting from a Grid with Dividers