Re: Support for PlotLegend in DateListPlot
- To: mathgroup at smc.vnet.net
- Subject: [mg109092] Re: Support for PlotLegend in DateListPlot
- From: Darren Glosemeyer <darreng at wolfram.com>
- Date: Mon, 12 Apr 2010 23:00:26 -0400 (EDT)
Thomas Melehan wrote: > Does anyone know if there any undocumented PlotLegend type functions that work in a DateListPlot? Using ShowLegend is too much work. > In current released versions, PlotLegend will work with DateListPlot if the date coordinates are AbsoluteTimes. The package code did not know how to handle data with DateList and DateString coordinates, but this is fixed in the version of Mathematica currently under development. For now, converting date coordinates to AbsoluteTimes will provide a workaround. Here is an example of how this can be done. << PlotLegends` data = FinancialData["AAPL", {2008, 11, 1}]; (* convert date coordinates to absolute times *) newdata = data; newdata[[All, 1]] = Map[AbsoluteTime, newdata[[All, 1]]]; (* plot the new data with a legend *) DateListPlot[newdata, PlotLegend -> {"AAPL"}] (* add legend options as desired *) DateListPlot[newdata, PlotLegend -> {"AAPL"}, LegendPosition -> {-1.1, -1}] Darren Glosemeyer Wolfram Research