Pandas Stacked Area Chart

logo of a chart:StackedArea

This post explains how to create a stacked area plot using the pandas library of python.

Using pandas library, the stacked area charts are plotted with the plot.area() function. Each column of your data frame will be plotted as an area on the chart.

# libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
 
# Dataset
df = pd.DataFrame(np.random.rand(10, 4), columns=['a', 'b', 'c', 'd'])
 
# plot
df.plot.area()

# show the graph
plt.show()

Timeseries

🚨 Grab the Data To Viz poster!


Do you know all the chart types? Do you know which one you should pick? I made a decision tree that answers those questions. You can download it for free!

    dataviz decision tree poster