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.
This post follows the previous basic streamgraph. It shows the effect of the offset
option that can take 3 values:
silhouette
: shapes are displayed on both side of an horizontal axiszero
: displayed on top of the 0 line.expand
: equivalent of a percent stacked area chart: the full height is used to visualize percentages.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) , 270)
)
# Type 1 (default)
p1 <- streamgraph(data, key="name", value="value", date="year" ,
offset="silhouette",
width="400px", height="300px"
)
# Type 2
p2 <- streamgraph(data, key="name", value="value", date="year" ,
offset="zero",
width="400px", height="300px"
)
# Type 3.
p3 <- streamgraph(data, key="name", value="value", date="year" ,
offset="expand",
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"))