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 want to plot a graph from list of points, but each point also has uncertainty assigned AND date. Without uncertainties DateListPlot works great, without dates ErrorListPlot works OK, but how it could be done both at the same time?

I tried displaying 2 plots (DateListPlot + ErrorListPlot) using Show, but it didn't work. Any ideas?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

The plots can't be directly combined because the PlotRange of the DateListPlot is far out to the right on the horizontal axis, since it corresponds to a large AbsoluteTime value. So we have to convert the ErrorListPlot to the same coordinate range before combining the plots using Show:

Needs["ErrorBarPlots`"]


data = {{{2006, 10, 1}, 10, 1}, {{2006, 10, 15}, 
    12, .1}, {{2006, 10, 30}, 15, 2}, {{2006, 11, 20}, 20, 1}};

data2 = 
 Map[{{AbsoluteTime[#[[1]]], #[[2]]}, ErrorBar[#[[3]]]} &, data]

(*
==> {{{3368649600, 10}, ErrorBar[1]}, {{3369859200, 12}, 
  ErrorBar[0.1]}, {{3371155200, 15}, ErrorBar[2]}, {{3372969600, 20}, 
  ErrorBar[1]}}
*)

errorp = ErrorListPlot[data2];

datep = DateListPlot[data[[All, 1 ;; 2]]];

Show[datep, errorp]

combined

share|improve this answer
    
Thank you very much! It works perfectly.^^ –  crobartie Feb 3 '13 at 18:29
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.