Basic Area Chart

logo of a chart:Area

This post describes how to draw a basic area chart using the matplotlib library of python.

There are 2 main functions to draw a basic area chart using matplotlib: fill_between() and stackplot() functions. I advise the fill_between() function which allows easier customisation. The stackplot() function also works, but it is more adapted for stacked area charts. The inputs are 2 numerical variables(x and y values) for both functions.

# libraries
import numpy as np
import matplotlib.pyplot as plt
 
# Create data
x=range(1,6)
y=[1,4,6,8,4]
 
# Area plot
plt.fill_between(x, y)

# Show the graph
plt.show()
 
# Note that we could also use the stackplot function
# but fill_between is more convenient for future customization.
#plt.stackplot(x,y)
#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