Stacked area chart with seaborn style

logo of a chart:StackedArea

The previous post describes how to draw a basic stacked area chart with matplotlib. In this post, you will see an example of stacked area chart with a seaborn theme.

You can benefit the seaborn style in your graphs by calling the set_theme() function of seaborn library at the beginning of your code:

# libraries
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

# set seaborn style
sns.set_theme()
 
# Data
x=range(1,6)
y=[ [1,4,6,8,9], [2,2,7,10,12], [2,8,5,10,6] ]
 
# Plot
plt.stackplot(x,y, labels=['A','B','C'])
plt.legend(loc='upper left')
plt.show()

Timeseries

Contact & Edit


👋 This document is a work by Yan Holtz. You can contribute on github, send me a feedback on twitter or subscribe to the newsletter to know when new examples are published! 🔥

This page is just a jupyter notebook, you can edit it here. Please help me making this website better 🙏!