8
$\begingroup$

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?

$\endgroup$
9
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Thank you very much! It works perfectly.^^ $\endgroup$ – crobartie Feb 3 '13 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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