1
$\begingroup$

Is it possible to add error bars in the x direction in a DateListPlot? It seems that a naive application of Around in this case makes Mathematica really mad...

I need to add error bars of 1 day (12 hours on the left and 12 hours on the right) to each day. Here are some of my data:

count = {3457, 3457, 3340, 3356, 3284, 3197, 3212, 3224, 3245, 3258, 3328, 3308};
date = {2016, 11, 21, 12, 0, 0};
time = NestList[DatePlus[#, Quantity[1, "Day"]] &, date, Length@count - 1];

Without the error bars I use the following for the plot:

TS=Transpose[{time,count}];
DateListPlot[TS]

I have tried to do the following:

time2=time;
ad = Around[time[[All, 4]], 12];
time2[[All, 4]] = ad;
TS2 = Transpose[{time2, count}];
DateListPlot[TS2]

but I get a bunch of errors.

If needed, my version is "13.0.1 for Linux x86 (64-bit) (January 29, 2022)".

$\endgroup$

1 Answer 1

3
$\begingroup$

Perhaps,

Show[DateListPlot @ TS, 
 ListLinePlot[{Around[AbsoluteTime @ #, 12 60 60], #2} & @@@ TS]
 PlotRange -> All]

enter image description here

$Version

"13.1.0 for Linux x86 (64-bit) (June 16, 2022)"

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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