Plot guides › Chart types

Dumbbell chart (before and after)

A dumbbell chart draws two dots per category joined by a line, making the size and direction of each change obvious, for example before vs after or 2020 vs 2024.

Example dumbbell chart (before and after) made with matplotlib
Rendered from the code below, with example data.

When to use it

Ask for it in pltchat

Upload your file and type something like:

"dumbbell chart of score in 2020 vs 2024 per department"

pltchat writes the loader and the plot for your columns, runs it in your browser and shows you the code.

The matplotlib code

Self-contained with example data; swap in pd.read_csv(...) or pd.read_excel(...) for your own file.

import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame({"dept": ["Sales", "Support", "Engineering", "Finance", "HR", "Legal"],
                   "2020": [62, 55, 71, 66, 58, 64],
                   "2024": [70, 68, 74, 61, 72, 65]})
df = df.assign(change=df["2024"] - df["2020"]).sort_values("change")

fig, ax = plt.subplots(figsize=(6.4, 4))
ax.hlines(df["dept"], df["2020"], df["2024"], color="lightgray", lw=3)
ax.plot(df["2020"], df["dept"], "o", ms=9, label="2020", color="C7")
ax.plot(df["2024"], df["dept"], "o", ms=9, label="2024", color="C0")
ax.set_xlabel("Engagement score")
ax.legend(loc="lower right")
ax.spines[["top", "right"]].set_visible(False)
plt.tight_layout()
plt.show()

Make this with your data

Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.

Related plots