1
$\begingroup$

I want to make a family tree. My approach is to use the birth year to structure the tree in abscissa. The issue is the ordinate positions of the according person. It may change when the family tree is update or changed. My code is:

 TimelinePlot[{
  {Labeled[Interval[{DatePlus[Today, -15000 ], Today}], "dad"], 
   Labeled[Interval[{DatePlus[Today, -14500 ], Today}], "mother"],
   Labeled[Interval[{DatePlus[Today, -5000 ], Today}], "me"], 
   Labeled[Interval[{DatePlus[Today, -6000 ], Today}], "sister"]},
  {Labeled[Interval[{DatePlus[Today, -4500 ], Today}], "partner"],
   Labeled[Interval[{DatePlus[Today, -600 ], Today}], "son 1"], 
   Labeled[Interval[{DatePlus[Today, -400 ], Today}], 
    "son 2"]}, {Labeled[Interval[{DatePlus[Today, -6800 ], Today}], 
    "bro inlaw"], 
   Labeled[Interval[{DatePlus[Today, -1800 ], Today}], "nephew 1"], 
   Labeled[Interval[{DatePlus[Today, -1200 ], Today}], "nephew 2"]}
  }, Epilog -> {
   Arrow[{{AbsoluteTime[DatePlus[Today, -15000 ]], 
      1}, {AbsoluteTime[DatePlus[Today, -5000 ]], 4}}],
   Arrow[{{AbsoluteTime[DatePlus[Today, -15000 ]], 
      1}, {AbsoluteTime@DatePlus[Today, -6000 ], 3}}],
   Arrow[{{AbsoluteTime[DatePlus[Today, -6800 ]], 
      8}, {AbsoluteTime@DatePlus[Today, -1800 ], 9}}],
   Arrow[{{AbsoluteTime[DatePlus[Today, -6800 ]], 
      8}, {AbsoluteTime@DatePlus[Today, -1200 ], 10}}],
   Arrow[{{AbsoluteTime[DatePlus[Today, -5000 ]], 
      4}, {AbsoluteTime@DatePlus[Today, -600 ], 6}}],
   Arrow[{{AbsoluteTime[DatePlus[Today, -5000 ]], 
      4}, {AbsoluteTime@DatePlus[Today, -400 ], 7}}]
   }]

enter image description here I use the arrows to indicate the parenthood. This arrow needs ordinate points for the parent and offspring (abscissa in known). Is it possible to set ordinate position for a given interval? Alternatively, is it possible to retrive the coordinates of a given interval (e.g. "partner")? Imagine I get another son or daughter. It all needs a new setup by hand right now.

$\endgroup$
  • $\begingroup$ if you sort the first argument of TimelinePlot by birthdates (that is, use Map[List]@SortBy[First]@(Join@@{{...},{...}}) as the first argument) it will be easier to associate dates with vertical coordinates. $\endgroup$ – kglr Aug 21 at 10:00
1
$\begingroup$

With input equal to the first argument of TimelinePlot in OP:

sortedinput = SortBy[#[[1, 1]] &] @ (Join @@ input);

birthdaysandorders = Association[
   MapIndexed[Last[#] -> {AbsoluteTime @ #[[1, 1, 1]], #2[[1]]} &, sortedinput]];

children = Association[{"dad" -> {"sister", "me"}, "me" -> {"son 1", "son 2"}, 
    "bro inlaw" -> {"nephew 1", "nephew 2"}}];

arrows = Join @@ KeyValueMap[Arrow /@ 
  Thread[{birthdaysandorders[#], birthdaysandorders /@ #2}, List, {2}] &, children];

TimelinePlot[List /@ sortedinput, Epilog -> {Arrowheads[Medium], arrows}]

enter image description here

You can add additional arrows as easily:

TimelinePlot[List /@ sortedinput, 
 Epilog -> {Arrowheads[Medium], arrows, 
  Dashed, Red, Arrow[birthdaysandorders /@ {"mother", "son 2"}]}]

enter image description here

Ordinate position of "partner":

Last @ birthdaysandorders["partner"]

6

$\endgroup$
  • 1
    $\begingroup$ That is what I was looking for. I need some time to figure out what you did in detail and how it works. A lot of programming learning for me in this answer. Then I can test if it works when adding more people. $\endgroup$ – Eisbär Aug 21 at 12:32

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.