Function Repository Resource:

AlluvialChart

Source Notebook

Chart changing weights over time

Contributed by: Michael Sollami

ResourceFunction["AlluvialChart"][{{w11,w12, }, {w21,w22,},}]

generates a chart of changing values wij over time.

ResourceFunction["AlluvialChart"][{g1,g2, }]

generates a chart changing vertex weights over a sequence of graphs gi.

Details and Options

ResourceFunction["AlluvialChart"] expects VertexWeightedGraphQ[g] to be True for all graphs in the list.
ResourceFunction["AlluvialChart"] returns a Graphics object representing a subcategory of a Sankey diagram, wherein the heights of the bands correspond to VertexWeight, nodes are grouped vertically and horizontal steps represent the sequence of graphs, typically time or date stamps, which increase temporally from left to right.
The following string options can be given in addition to the standard Graphics options:
"CenteredMidline"Falsewhether to vertically center the columns
"ColorList"Automaticlist of colors to use for the vertices
"EdgeForm"Whitespecify the EdgeForm for the filled curves
"HorizontalLabels"Nonespecify the labels on graphs
"Spacings"Automatichow much to space the bands
"VerticalLabels"Nonespecify the labels for the vertices

Examples

Basic Examples (2) 

Construct a simple alluvial diagram from lists of numeric values:

In[1]:=
ResourceFunction[
 "AlluvialChart"][{{1, 1, 1, 2}, {1, 1, 1, 1.5}, {1, 1, 1, 1}}, ImageSize -> 250]
Out[1]=

Construct a simple alluvial diagram from vertex weights:

In[2]:=
gs = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1}, VertexWeight -> #] & /@ {{1, 2, 6}, {3, 2, 3}, {6, 2, 1}};
ResourceFunction["AlluvialChart"][gs, ImageSize -> 250]
Out[2]=

Scope (3) 

Construct an alluvial chart using edge weights instead (by taking the dual of a Graph):

In[3]:=
gs = LineGraph@
     Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1}, EdgeWeight -> #] & /@ {{1, 2, 6}, {3, 2, 3}, {6, 2, 1}};
ResourceFunction["AlluvialChart"][gs, "ColorList" -> {Hue[0.1], Hue[0.4], Hue[0.6]}, AspectRatio -> 1/3]
Out[4]=

Create an alluvial chart and specify the labels and colors:

In[5]:=
gs = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1, 2 \[DirectedEdge] 4}, VertexWeight -> #] & /@ {{4, 1, 1, 2}, {3, 2, 1, 3}, {2, 1, 2, 2}, {1.5, 1, 3, 1}, {2.5, 4, 2, 2}, {2, 2.3, 1.2, 1}};
vlbls = Table[Subscript["v", i], {i, 4}]; hlbls = Table[Subscript["g", i], {i, 6}];
cols = ResourceFunction["SampleColors"]["BrightBands", 4];
ResourceFunction["AlluvialChart"][gs, "HorizontalLabels" -> hlbls, "VerticalLabels" -> vlbls, ImageSize -> 400, "ColorList" -> cols]
Out[5]=

Create a random alluvial chart:

In[6]:=
gs = Graph[Range[10], {}, VertexWeight -> #] & /@ RandomReal[{0, 10}, {20, 10}]; ResourceFunction["AlluvialChart"][gs,
  ImageSize -> 400, "ColorList" -> ColorData[96, "ColorList"], "EdgeForm" -> {Black, Thickness[0.001]}]
Out[6]=

Options (1) 

Specify that the vertical-midline should be centered:

In[7]:=
gs = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1}, VertexWeight -> #] & /@ {{2, 2, 2}, {2, 2, 5}, {5, 2, 2}};
In[8]:=
Labeled[ResourceFunction["AlluvialChart"][gs, ImageSize -> 200, "CenteredMidline" -> #, "HorizontalLabels" -> {"\!\(\*SubscriptBox[\(g\), \(1\)]\)", "\!\(\*SubscriptBox[\(g\), \(2\)]\)", "\!\(\*SubscriptBox[\(g\), \(3\)]\)"}], "\"CenteredMidline\"" -> #] & /@ {True, False}
Out[8]=

Publisher

Michael Sollami

Version History

  • 1.0.0 – 29 June 2020

License Information