3
$\begingroup$

What I want is to associate the pairs of a nested list, like this: Association[{11 -> DateObject[{2019, 6, 4}, "Day", "Gregorian", -5.]}... ] and so on.

So when a plot it with the TimeLinePlot I would get something like the picture, and when I pass the cursor over the number I would get the date.1

Here is the whole nested list:

dates = {{11, DateObject[{2019, 6, 4}, "Day", "Gregorian", -5.]}, 
           {22, DateObject[{2019, 6, 6}, "Day", "Gregorian", -5.]}, 
           {33, DateObject[{2019, 6, 7}, "Day", "Gregorian", -5.]}, 
           {41, DateObject[{2019, 6, 1}, "Day", "Gregorian", -5.]}, 
           {53, DateObject[{2019, 6, 8}, "Day", "Gregorian", -5.]}, 
           {63, DateObject[{2019, 6, 8}, "Day", "Gregorian", -5.]}, 
           {72, DateObject[{2019, 6, 6}, "Day", "Gregorian", -5.]}, 
           {38, DateObject[{2019, 6, 9}, "Day", "Gregorian", -5.]}, 
           {92, DateObject[{2019, 6, 21}, "Day", "Gregorian", -5.]}, 
           {130, DateObject[{2019, 6, 26}, "Day", "Gregorian", -5.]}}   
$\endgroup$
3
$\begingroup$
TimelinePlot[Association[Rule @@@ dates]]

... or alternatively:

TimelinePlot[AssociationThread[dates[[All, 1]] -> dates[[All, 2]]]]
| improve this answer | |
$\endgroup$
  • $\begingroup$ Or TimelinePlot@Association[Rule @@@ dates]. $\endgroup$ – Rohit Namjoshi Jun 23 at 0:37
  • 1
    $\begingroup$ @RohitNamjoshi I already did that in the edit $\endgroup$ – flinty Jun 23 at 0:38

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.