
What is a Streamgraph?
A streamgraph is a type of visualization used to display changes in data values over time, in a way that's visually engaging and often aesthetically pleasing. Unlike traditional line or bar graphs, stream graphs use flowing, organic shapes that resemble streams or rivers, making them particularly effective for showing overlapping data sets with dynamic trends.
Each "stream" in the graph represents a category or data set, and the width of the stream at any given point corresponds to the value of that data at a specific time. These streams are stacked on top of each other, creating a layered appearance. Stream graphs are commonly used in fields like data journalism, music streaming trends, and social media analytics to illustrate evolving patterns.
Step-by-step guide
To create a streamgraph in R, install and load the required packages as shown below.

Set your working directory and load the dataset as shown below.

In this example, I am using the “store_data” shown below.

Create a streamgraph using ggplot and geom_stream functions as shown below.

Executing the above code results in the view below.

Note, by default the streams are stacked symmetrically around the x-axis. However, you can use other options such as “ridge” – which stacks the streams from the x-axis or “proportional” - which makes the streams sum up to 1.
See the codes, for the stream graph types.

Executing the above results in.

Using paletteer package you can customize color as shown below.

Executing the above code results in.

Lastly, you can declutter your view using theme_minimal as shown below.

Executing the above results in.

Conclusion
Creating a stream graph in R is a straightforward and rewarding process that combines thoughtful data preparation with the powerful visualization capabilities of libraries like ggplot2 and ggstream. By ensuring your data is structured properly and exploring customization options, you can design compelling stream graphs that effectively illustrate trends over time. Whether for research, presentations, or data storytelling, stream graphs are a creative way to transform complex datasets into visually engaging narratives. With the tools and guidance provided, you're equipped to bring dynamic visualizations to life.
If you like the work we do and would like to work with us, drop us an email on our contacts page and we’ll reach out!
Thank you for reading!