in

Methods to Create a Lipstick Chart with Matplotlib | by Oscar Leo | Sep, 2023


Matplotlib Tutorial

An information visualization when the decrease the worth, the higher

Immediately, I’ll present you create a lipstick chart for visualizing progress on metrics the place the decrease the worth, the higher.

It’s good when metrics have comparable traits and subjects however not the identical scale. My goal is to share a message reasonably than “simply” a plot.

I’ve ready a easy dataset about mortality and illnesses so as to deal with creating the visualization.

The info comes from the World Bank and is publicly out there beneath Inventive Commons licenses. If you wish to study extra, I’ve written concerning the visualization in my new free publication, Data Wonder.

Let’s get began.

Step 1 – Importing libraries

The primary and easiest half 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 Picture
from matplotlib.strains import Line2D

Congratulations, you simply accomplished step 1! 🥳

Step 2 — Create a Seaborn type

Subsequent, I wish to create a colour scheme and choose a font. Websites like Coolors and Colorhunt are nice assets when trying to find lovely colours.

Right here’s my code and settings to create the seaborn type for this tutorial.

FONT_FAMILY = "serif"
BACKGROUND_COLOR = "#FAE8E0"
TEXT_COLOR = "#33261D"
BAR_COLOR = "#EF7C8E"

sns.set_style({
"axes.facecolor": BACKGROUND_COLOR,
"determine.facecolor": BACKGROUND_COLOR,
"textual content.colour": TEXT_COLOR,
"font.household": FONT_FAMILY,
"xtick.backside": False,
"xtick.high": False,
"ytick.left": False,
"ytick.proper": False,
"axes.spines.left": False,
"axes.spines.backside": False,
"axes.spines.proper": False,
"axes.spines.high": False,
})

I’m eradicating all of the ticks and features to create a clear visualization, and the grids don’t add invaluable data to our lipstick chart.

Step 3 — Studying the information

Euro Journey Optimization: Genetic Algorithms and Google Maps API Remedy the Touring Salesman Downside | by Riccardo Andreoni | Sep, 2023

The Final Information to Coaching BERT from Scratch