Most basic streamgraph



This post describes how to build a basic streamgraph using R and the streamgraph package. It provides the reproducible code and explanation.

Streamgraph section Data to Viz

This post describe the basic use of the streamgraph package. Your input needs 3 columns:

The streamgraph() function requires those 3 inputs to work.

Note: The streamgraph package is a work by xxx. It lives on github.

Note: you can save the chart as a html file using the saveWidget() function of the htmlwidgets package, as suggested in the commented code below.

# Library
library(streamgraph)
 
# Create data:
data <- data.frame(
  year=rep(seq(1990,2016) , each=10),
  name=rep(letters[1:10] , 27),
  value=sample( seq(0,1,0.0001) , length(year))
)
 
# Basic stream graph: just give the 3 arguments
pp <- streamgraph(data, key="name", value="value", date="year", height="300px", width="1000px")
pp 

# save the widget
# library(htmlwidgets)
# saveWidget(pp, file=paste0( getwd(), "/HtmlWidget/streamgraphBasic.html"))

Related chart types


Line plot
Area
Stacked area
Streamchart



Contact

This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message on Twitter, or send an email pasting yan.holtz.data with gmail.com.

Github Twitter