Control streamgraph offset

The streamgraph package offers several options concerning the chart offset. This feature has a massive impact on the general appearance. This post provides a description of the options.

Streamgraph section Data to Viz

This post follows the previous basic streamgraph. It shows the effect of the offset option that can take 3 values:

Note: The streamgraph package is a work by Bob Rudis. 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

# 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) , 270)

# Type 1 (default)
p1 <- streamgraph(data, key="name", value="value", date="year" , 
    width="400px", height="300px"
# Type 2 
p2 <- streamgraph(data, key="name", value="value", date="year" , 
    width="400px", height="300px"
# Type 3.
p3 <- streamgraph(data, key="name", value="value", date="year" , 
    width="400px", height="300px"

# save the widget
# library(htmlwidgets)
# saveWidget(p1, file=paste0( getwd(), "/HtmlWidget/streamgraphOffset1.html"))
# saveWidget(p2, file=paste0( getwd(), "/HtmlWidget/streamgraphOffset2.html"))
# saveWidget(p3, file=paste0( getwd(), "/HtmlWidget/streamgraphOffset3.html"))

Related chart types

Line plot
Stacked area
Time Series


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 with

Github Twitter