Ready to curb your Power BI skills? Find out more here!
Welcome to our Knowledge Base

Tip: Start typing in the input box for immediate search results.

Print

Area charts in Matplotlib

In this tutorial I will show you how to create Area charts using Python and Matplotlib.

Important notes:

1. This are my personal notes, so apologies if some explanations and notations are missing.
2. Most of the sources can be downloaded from data.world as the data is from Makeover Monday challenges. Look for the week and year in the source URL.

Area charts in matplotlib

This is what we will be creating:

Video Tutorial

If you prefer video, watch it here:

Chapters:
00:00 Intro
01:14 Import a csv with pandas
02:20 Pivot tables in pandas
02:30 Drop columns in pandas table
03:00 Get data from a pivoted column index in pandas
03:30 Get data from a column in pandas
04:30 Define the chart in matplotlib (ax method)
05:00 ax.fillbetween function matplotlib
07:18 ax.annotate Annotate function in matplotlib
07:55 ax.annotate with bbox Annotations with border matplotlib
10:33 ax.axvline Vertical line in matplotlib
11:50 ax.annotate with offset and arrow matplotlib
15:00 ax.set_ylabel – add y axis title
15:35 ax.spines – Modify the frame or spines
15:57 ax.tick_params – Change color of x-y axis labels
16:12 ax.grid -add horizonal lines to the y axis
16:20 ax.set_axisbelow(True) – send the horizonal lines to the back
16:44 ax.set_ylim – start the y axis by zero
17:10 ax.set_yticklabels -add % to the axis labels

Matplotlib #1: Area charts

The notebook

Was this helpful?

Reader Interactions

Let us know your thoughts...

Table of Contents