How to Create a Lipstick Chart with Matplotlib

Author:Murphy  |  View: 25572  |  Time: 2025-03-23 12:51:12

Matplotlib Tutorial

Today, I will show you how to create a lipstick chart for visualizing progress on metrics where the lower the value, the better.

It's perfect when metrics have similar trends and topics but not the same scale. My aim is to share a message rather than "just" a plot.

I've prepared a simple dataset about mortality and diseases so that you can focus on creating the visualization.

The data comes from the World Bank and is publicly available under Creative Commons licenses. If you want to learn more, I've written about the visualization in my new free newsletter, Data Wonder.

If you enjoy this tutorial, make sure to take a look at my other ones as well.

Matplotlib Tutorials

Let's get started.


Step 1 – Importing libraries

The first and simplest part is to import the required libraries like pandas and matplotlib.

import numpy as np
import pandas as pd

import seaborn as sns
import matplotlib.pyplot as plt

from PIL import Image
from matplotlib.lines import Line2D

Congratulations, you just completed step 1!

Tags: Data Visualization Learning To Code Matplotlib Python Tutorial

Comment