2
$\begingroup$

I have tried to simplify this issue as much as I can at the moment: it looks like a bug to me but perhaps I've missed something obvious.

I am trying to build an interactive scheduler using TimelinePlot and I find that the following code reports that I've tried to plot an invalid dataset:

Manipulate[Column@{DatePlus[{2019, 1, 15}, sdate],
TimelinePlot[{{Labeled[{2011, 1, 1}, "hello"], {2012, 1, 1}, {2013, 1, 1}}, 
    {Labeled[Interval[{{2011, 3, 1}, {2012, 7, 7}}], mylabel], 
     Interval[{{2012, 9, 12}, {2013, 12, 21}}]}, {Labeled[
     Interval[{DatePlus[{2011, 3, 1}, sdate], 
     DatePlus[{2012, 7, 7}, sdate]}], "Moving interval"], 
     Labeled[Interval[{{2012, 9, 12}, {2013, 12, 21}}], "Range"]}}]}, 
  {sdate, 0, 200, 1}, 
  {mylabel, {"la", "lb", "lc"}}]

Mathematica graphics

but this works fine

Manipulate[Column@{DatePlus[{2019, 1, 15}, sdate],
TimelinePlot[{{{2011, 1, 1}, {2012, 1, 1}, {2013, 1, 1}}, 
{Labeled[
   Interval[{{2011, 3, 1}, {2012, 7, 7}}], mylabel], 
   Interval[{{2012, 9, 12}, {2013, 12, 21}}]}, 
{Labeled[
   Interval[{DatePlus[{2011, 3, 1}, sdate], 
     DatePlus[{2012, 7, 7}, sdate]}], "Moving interval"], 
   Labeled[Interval[{{2012, 9, 12}, {2013, 12, 21}}], 
   "Range"]}}]}, {sdate, 0, 200, 1}, 
{mylabel, {"la", "lb", "lc"}}]

Mathematica graphics

as well as this:

With[{sdate = 1, mylabel = "foo"},
 Column@{DatePlus[{2019, 1, 15}, sdate],
 TimelinePlot[{{Labeled[{2011, 1, 1}, "hello"], {2012, 1, 1}, {2013,
    1, 1}}, {Labeled[Interval[{{2011, 3, 1}, {2012, 7, 7}}], 
   mylabel], 
  Interval[{{2012, 9, 12}, {2013, 12, 21}}]}, {Labeled[
   Interval[{DatePlus[{2011, 3, 1}, sdate], 
     DatePlus[{2012, 7, 7}, sdate]}], "Moving interval"], 
  Labeled[Interval[{{2012, 9, 12}, {2013, 12, 21}}], "Range"]}}]}]

Mathematica graphics

$\endgroup$
1
$\begingroup$

Looks like a bug. Two smaller examples exhibiting two aspects of the issue:

(1) TimelinePlot[{{Labeled[{2011, 3, 1}, "Label"]}}] works as expected but Manipulate[TimelinePlot[{{Labeled[{2011, 3, 1}, "Label"]}}], {sdate, 0, 200, 1}] gives an error.

(2) Although TimelinePlot[{{{2011, 3, 1}, Interval[{{2011, 3, 1}, DatePlus[{2011, 3, 1}, 100]}]}}] works fine, inside Manipulate it gives an error message. In general, if any element of datai in TimeLinePlot[{data1, ..., datan}] is a date list ({y,m,d,...}) without wrappers all elements of datai should be date lists without wrappers.

A work-around: Wrap the date lists with DateObject (or DateList or AbsoluteTime), that is, use

{Labeled[DateObject@{2011, 1, 1}, "hello"], DateObject@{2012, 1, 1}, DateObject@{2013, 1, 1}}

in the first sublist of your input data to get

enter image description here

$\endgroup$
5
  • $\begingroup$ yes, that seems to fix it thanks $\endgroup$ – fairflow Dec 21 '18 at 13:42
  • $\begingroup$ just waiting to see if it is confirmed as a bug and if that's the best workaround. $\endgroup$ – fairflow Dec 21 '18 at 13:43
  • $\begingroup$ well, I haven't asked via the official route if it's a bug; it could be called a design choice but I prefer to mark it as a bug. Only I'm not quite sure how to do that, I'll have to find out what the standard bug headers are... $\endgroup$ – fairflow Jan 2 '19 at 17:29
  • $\begingroup$ @fairflow, please see How to report a bug in Mathematica. $\endgroup$ – kglr Jan 3 '19 at 23:35
  • $\begingroup$ yes @kglr thanks for the prompt; but actually I wanted to know how to add a bug tag to a question and the advice is not just to add the tag bug but to use the "standard bug headers" instead and I didn't know what that meant. $\endgroup$ – fairflow Jan 5 '19 at 10:11

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.