Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is there a way to use DateListPlot with Quantity values? I retrieved the following time series data from WolframAlpha:

gasPrices = WolframAlpha[
"us gas prices", {{"History:Price:GasPriceData", 1}, 
"TimeSeriesData"}];

Each data point is composed of a date and a Quantity:

{{{1993, 4, 5, 0, 0, 0.}, Quantity[1.068, ("USDollars")/("Gallons")]},
 {{1993, 4, 19, 0, 0, 0.}, Quantity[1.079, ("USDollars")/("Gallons")]},
...
 {{2012, 12, 31, 0, 0, 0.}, Quantity[3.369, ("USDollars")/("Gallons")]} }

I can plot the values using ListPlot:

 ListPlot[gasPrices[[All,2]]]

enter image description here

Strangely however, DateListPlot produces an empty plot:

 DateListPlot[gasPrices]

Empty plot from DateListPlot

To get DateListPlot to produce a proper plot I have to do this instead:

DateListPlot[ Transpose[{gasPrices[[All, 1]], gasPrices[[All, 2, 1]]}] ]

OK plot from DateListPlot

Am I missing something? I would have thought that Quantity values could be taken directly by DateListPlot, as they are by ListPlot.

share|improve this question
    
I tested your code and it seems that Units are not properly implemented in DateListPlot –  Murta Jan 5 '13 at 18:36
    
You can also do: DateListPlot[QuantityMagnitude[gasPrices]] to remove the units. –  ecoxlinux Jan 15 '13 at 5:23
add comment

1 Answer 1

up vote 4 down vote accepted

This appears to work in the 9.0.1 release:

 DateListPlot[gasPrices]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.