How to Draw Interactive Steamgraph in R
Streamgraph is a type of stacked area graph which is displaced around a central axis, resulting in a flowing, organic shape. Streamgraphs and their use were popularized by Lee Byron in a February 2008 New York Times article on movie box office revenues.
Here we have census data about GDP values in some counties in southeast China.
We have a 2-dimensional table above. Before drawing streamgraph, we need to convert 2-dimensional table to 1-dimensional table. We can use
Microsoft Excel to convert it.
Alt + D + P, then we have the widget.
Select the data need to be ploted.
Now we have a new table,
double click the bottom right sum value. Then we will have a 1-dimensional table.
read_csv can not read Chinese characters correctly, we use
read_excel to input the data.
streamgraph package from github.
Draw the graph；
streamgraph(df, key="name", value="gdp", date="year" , offset="zero") %>%