hrbrmstr / streamgraph

:wavy_dash: htmlwidget for creating streamgraph visualizations in R
http://hrbrmstr.github.io/streamgraph/
Other
147 stars 49 forks source link
data-visualisation data-visualization htmlwidgets r rstats streamgraph

streamgraph

streamgraph is an htmlwidget for making, well, streamgraphs.

example

Sample Rmd

A streamgraph (or "stream graph") is a type of stacked area graph which is displaced around a central axis, resulting in a flowing, organic shape. Streamgraphs were developed by Lee Byron and popularized by their use in a February 2008 New York Times article on movie box office revenues. (Wikipedia)

The x axis values can be continous or dates.

TODO

The following functions are implemented:

News

Installation

devtools::install_github("hrbrmstr/streamgraph")

Usage

library(streamgraph)

# current verison
packageVersion("streamgraph")

library(dplyr)

ggplot2movies::movies %>%
  select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
  tidyr::gather(genre, value, -year) %>%
  group_by(year, genre) %>%
  tally(wt=value) -> dat

streamgraph(dat, "genre", "n", "year", interactive=TRUE) %>%
  sg_axis_x(20, "year", "%Y") %>%
  sg_fill_brewer("PuOr")

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.