Skip to content Skip to footer

5 Steps to Beautiful Stacked Area Charts in Python


How to use the full capabilities of Matplotlib to tell a more compelling story

Electricity Production by Source in the US — Image by Author

Telling a compelling story with data gets way easier when the charts supporting this very story are clear, self-explanatory and visually pleasing to the audience.

In many cases, substance and form are just equally important.
Great data poorly presented will not catch the attention it deserves while poor data presented in a slick way will easily be discredited.

I hope this will resonate with many Data Analysts, or anyone who had to present a chart in front an audience once in their lifetime.

Matplotlib makes it quick and easy to plot data with off-the-shelf functions but the fine tuning steps take more effort.
I spent quite some time researching best practices to build compelling charts with Matplotlib, so you don’t have to.

In this article I focus on stacked area charts and explain how I stitched together the bits of knowledge I found here and there to go from this…

… to that:

All images, unless otherwise noted, are by the author.

To illustrate the methodology, I used a public dataset containing details about how the US are producing their electricity and which can be found here — https://ourworldindata.org/electricity-mix.

On top of being a great dataset to illustrate stacked area charts, I also found it very insightful.

Source: Ember — Yearly Electricity Data (2023); Ember — European Electricity Review (2022); Energy Institute — Statistical Review of World Energy (2023)
License URL:
https://creativecommons.org/licenses/by/4.0/
License Type: CC BY-4.0



Source link