From: divisor on
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

From: Darren Glosemeyer on
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

From: Tyler on
Yup. Same thing on my Mac. The only way I could get something to work
was by converting the dates to AbsoluteTime like so:

Needs["PlotLegends`"]
ibm = FinancialData["IBM", {2000, 1, 1}];
msft = FinancialData["MSFT", {2000, 1, 1}];
ibm = Transpose[{AbsoluteTime /@ ibm[[All, 1]], ibm[[All, 2]]}];
msft = Transpose[{AbsoluteTime /@ msft[[All, 1]], msft[[All, 2]]}];
p1 = DateListPlot[{ibm, msft}, Joined -> True,
PlotLabel -> "Apple vs. MicroSoft",
FrameLabel -> {"Date", "Price (USD)"},
PlotLegend -> {"APPL", "MSFT"}, LegendSize -> {0.5, 0.2},
LegendTextSpace -> 6, LegendShadow -> None,
LegendPosition -> {0, -0.4}];
Show[p1, ImageSize -> 470]

Cheers,

t.


From: Bob Hanlon on
Use Show Legend

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}};

ShowLegend[DateListPlot[
{data1, data2},
Joined -> True,
ImageSize -> 600,
PlotStyle -> {Lighter[Blue], Darker[Red]}],
{{
{Graphics[{Lighter[Blue],
Line[{{0, 0}, {1, 0}}]}], First},
{Graphics[{Darker[Red],
Line[{{0, 0}, {1, 0}}]}], Second}},
LegendPosition -> {0.9, -0.2},
LegendSize -> {0.35, 0.35},
LegendShadow -> None}]


Bob Hanlon

---- divisor <congruentialuminaire(a)yahoo.com> 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