Alex Rivera | Logout

Streamgraphs in R?

Asked 2012-10-26T10:16:40.240
36

How can I implement Streamgraphs in R?

Streamgraphs are a variant of stacked graphs and an improvement on Havre et al.'s ThemeRiver in the way the baseline is chosen, layer ordering, and color choice.

Example:

enter image description here

Reference: http://www.leebyron.com/else/streamgraph/

Edit
Report

1 Answer

9

Adding one line to Marc in the box's nifty code will get you much closer. (Getting the rest of the way will just be a matter of setting fill colors based on the max height of each curve.)

## reorder the columns so each curve first appears behind previous curves
## when it first becomes the tallest curve on the landscape
y <- y[, unique(apply(y, 1, which.max))]

## Use plot.stacked() from Marc's post
plot.stacked(x,y)

enter image description here

answered 2012-10-26T15:54:48.847

Your Answer