Function Repository Resource:

LifetimeChart

Source Notebook

Visualize a lifetime in weeks or months

Contributed by: Michael Sollami

ResourceFunction["LifetimeChart"][]

charts a human lifetime as a grid of weeks.

ResourceFunction["LifetimeChart"][age]

charts a human lifetime grid for a human of a given age.

Details and Options

ResourceFunction["LifetimeChart"] assumes a lifetime of 90 years.
The given age should be a Quantity of time or a numeric value, which is assumed to be in "Years"
ResourceFunction["LifetimeChart"] takes the following special options:
Appearance"Vertical"may be either "Horizontal" or "Vertical"
"FutureStyle"Automaticstyling Directive for grid items in future
"Granularity""Week"chart by "Week", "Month", or "Year"
"Grouped"Trueadd spacing to show groups of 40⨯10 items
"PastStyle"Automaticstyling Directive for grid items in past
"Shape""Square"specifies the grid item to use ("Disk" or "Square")
Spacings1scale the spacings of charted items
ResourceFunction["LifetimeChart"] additionally accepts the standard options AxesLabel, Background, BaseStyle, LabelStyle

Examples

Basic Examples (1) 

Chart a life in months (a row is 3-years):

In[1]:=
ResourceFunction["LifetimeChart"][\!\(\*
NamespaceBox["LinguisticAssistant",
DynamicModuleBox[{Typeset`query$$ = "36 months", Typeset`boxes$$ = TemplateBox[{"36", "\"mo\"", "months", "\"Months\""}, "Quantity",
       SyntaxForm -> Mod], Typeset`allassumptions$$ = {}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1, 2}, Typeset`querystate$$ = {"Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.593903, "Messages" -> {}}}, 
DynamicBox[ToBoxes[
AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, 
Dynamic[Typeset`query$$], 
Dynamic[Typeset`boxes$$], 
Dynamic[Typeset`allassumptions$$], 
Dynamic[Typeset`assumptions$$], 
Dynamic[Typeset`open$$], 
Dynamic[Typeset`querystate$$]], StandardForm],
ImageSizeCache->{81.8, {10., 17.8}},
TrackedSymbols:>{Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}],
DynamicModuleValues:>{},
UndoTrackedVariables:>{Typeset`open$$}],
BaseStyle->{"Deploy"},
DeleteWithContents->True,
Editable->False,
SelectWithContents->True]\), "Granularity" -> "Month", Magnification -> .25]
Out[1]=

Scope (3) 

Set the option "Granularity""Month" to chart by months:

In[2]:=
ResourceFunction["LifetimeChart"][Quantity[30, "Years"], "Granularity" -> "Month", "Grouped" -> True, Magnification -> .3, "PastStyle" -> Black, "FutureStyle" -> LightBlue]
Out[2]=

Set the option "Granularity""Year" to chart by years:

In[3]:=
a = 0;
In[4]:=
Column@{Slider[Dynamic[a], {0, 90}, Appearance -> "Labeled"], Dynamic@ResourceFunction["LifetimeChart"][a, "Granularity" -> "Year", Magnification -> .6, AxesLabel -> None]}
Out[4]=

Plot a life in weeks (a row is a year) with custom styling and layout:

In[5]:=
lp = ResourceFunction["LifetimeChart"][Quantity[15*52, "Weeks"], Magnification -> .2,
  "PastStyle" -> Directive[EdgeForm[None], FaceForm[Hue[.6, 1, 1, .6]]],
  "FutureStyle" -> Directive[EdgeForm@Hue[.6, 1, 1, .8], FaceForm@None],
   "Shape" -> "Disk", "Grouped" -> True, Spacings -> .5, AxesLabel -> {Style["\[LongLeftArrow]  Weeks  \[LongRightArrow]", 40, Bold], Style[Rotate["Years" , 90 \[Degree]], 40, Bold]}, BaseStyle -> Directive[FontFamily -> 60]]
Out[5]=

Use an inverted color scheme and horizontal layout:

In[6]:=
lp = ResourceFunction["LifetimeChart"][Quantity[35.5, "Years"], Magnification -> .2, "Shape" -> "Disk", "PastStyle" -> Directive[FaceForm@Orange, EdgeForm@{Black, Thin}], "FutureStyle" -> Directive[FaceForm@Cyan, EdgeForm@{Gray, Thickness@Medium}], Appearance -> "Horizaontal", Background -> Black, "Grouped" -> True,
  LabelStyle -> Directive[FontFamily -> "Verdana", FontSize -> 50, FontColor -> White]]
Out[6]=

Possible Issues (2) 

Setting the Magnification option will decrease resolution of an exported "PDF":

In[7]:=
Export[file = CreateFile["lifetime-chart.pdf"],
  ResourceFunction["LifetimeChart"][Quantity[45, "Years"], Magnification -> .1]];
In[8]:=
Import[file, "PageImages"][[1]]
Out[8]=

Charting in "Years" may result in seemingly extra weeks (one year is 365/7 weeks):

In[9]:=
Row@{ResourceFunction["LifetimeChart"][Quantity[21*52, "Weeks"], "Shape" -> "Disk", Magnification -> .1], ResourceFunction["LifetimeChart"][Quantity[21.0, "Years"], "Shape" -> "Disk", Magnification -> .1]}
Out[9]=

Publisher

Michael Sollami

Version History

  • 1.0.0 – 04 January 2021

License Information