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.

I'm working with economic data and realized that I could extract it directly from WolframAlpha using _Mathematica. So I did it. I extracted the GDP data of the country I'm studying.

nominal = 
  WolframAlpha[
   "nominal gdp of brazil", {{"History:GDP:WorldDevelopmentData", 1}, 
    "TimeSeriesData"}, 
   PodStates -> {"History:GDP:WorldDevelopmentData__Linear scale"}];

So until now I'm ok. The trouble begins when I try to plot it using DateListPlot[nominal] because I just get an empty frame? I noticed that the GDP comes in US dollars and maybe some additional parameters are needed. I looked for it in the doc but couldn't find the solution. Thank's for the help.

Here goes a sample of what I got

{{{1960, 1, 1, 0, 0, 0.}, Quantity[1.51656*10^10, ("USDollars")/("Years")]},
   {{1961, 1, 1, 0, 0, 0.}, Quantity[1.52369*10^10, ("USDollars")/("Years")]},
   {{1962, 1, 1, 0, 0, 0.}, Quantity[1.99263*10^10, ("USDollars")/("Years")]},
   {{1963, 1, 1, 0, 0, 0.}, Quantity[2.30215*10^10, ("USDollars")/("Years")]},
   {{1964, 1, 1, 0, 0, 0.}, Quantity[2.12119*10^10, ("USDollars")/("Years")]},
   {{1965, 1, 1, 0, 0, 0.}, Quantity[2.179*10^10, ("USDollars")/("Years")]},
   {{1966, 1, 1, 0, 0, 0.}, Quantity[2.70627*10^10, ("USDollars")/("Years")]},
   {{1967, 1, 1, 0, 0, 0.}, Quantity[3.05918*10^10, ("USDollars")/("Years")]},
   {{1968, 1, 1, 0, 0, 0.}, Quantity[3.38759*10^10, ("USDollars")/("Years")]},
   {{1969, 1, 1, 0, 0, 0.}, Quantity[3.74589*10^10, ("USDollars")/("Years")]}.........
share|improve this question
    
He goes a sample –  DiegoOliveira Dec 29 '13 at 21:26
    
Nice to see another Brazilian user here! –  Murta Dec 30 '13 at 10:13
    
Don't forget to upvote and accept useful answers. (You now have three questions and no accepted answers.) –  Ajasja Dec 30 '13 at 10:25

1 Answer 1

I have no idea why DateListPlot does not work with Quantity. Perhaps it's a bug?

But the workaround is very easy: using pattern replacements we extract the numerical values.

DateListPlot[nominal /. Quantity[x_, _] :> x, 
   FrameLabel -> {"year", "$ per year"}] 

example


Browsing through the help, another option is QuantityMagnitude.

DateListPlot@QuantityMagnitude@nominal

Part is also very versatile. This should get rid of units:

ListPlot@nominal[[All, {1, 2}, 1]] 

Note that this only works because we take just the first part of the date (the year).

share|improve this answer
    
Thank you @Ajasja! Great! But I wonder that the real issue is : Weren't MM supposed to deal with the units automatically when plotting? Is there a way to do that? –  DiegoOliveira Dec 29 '13 at 22:00
    
@DiegoOliveira No idea, I don't the new units that often. –  Ajasja Dec 30 '13 at 9:09

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.