A Stream graph is a type of stacked area chart. It displays the evolution of a numeric value (Y axis) following another numeric value (X axis). This evolution is represented for several groups, all with a distinct color.
Contrary to a stacked area, there is no corner: edges are rounded what gives this nice impression of flow. Moreover, areas are usually displaced around a central axis, resulting in a flowing and organic shape.
The following example shows the evolution of baby name frequencies in the US between 1880 and 2015.
# Libraries
library(tidyverse)
library(babynames)
library(streamgraph)
# Load dataset from github
data <- babynames %>%
filter(name %in% c("Ashley", "Amanda", "Jessica", "Patricia", "Linda", "Deborah", "Dorothy", "Betty", "Helen")) %>%
filter(sex=="F")
# Plot
data %>%
streamgraph(key="name", value="n", date="year") %>%
sg_fill_brewer("BuPu")
Note: The dataset is available through the babynames R library and a
.csv
version is available on github.
Streamchart are good to study the relative proportions
of the whole. However they are bad to study the evolution of each
individual group
: it is very hard to substract the height
of other groups at each time point. For a more accurate but less
attractive figure, consider a line chart or area chart using
small multiple.
Stream chart gets really useful when displayed in an interactive mode: highlighting a group gives you directly an insight of its evolution.
Even if areas are usually displaced around a central axis, it is possible to display them as for most of the chart type: over the 0 axis.
# Plot
data %>%
streamgraph(key="name", value="n", date="year", offset="zero") %>%
sg_fill_brewer("BuPu")
It also possible to create a percent streamchart where the proportion of each group is displayed instead of its absolute value. Here, the total number of baby names is not available anymore. However, the most popular names at each period gets more obvious.
Data To Viz is a comprehensive classification of chart types organized by data input format. Get a high-resolution version of our decision tree delivered to your inbox now!
A work by Yan Holtz for data-to-viz.com