Plot guides › Chart types

Lollipop chart

A lollipop chart replaces each bar with a thin line and a dot, cutting the ink of a bar chart while keeping the ranking easy to read. It suits many categories with similar values.

Example lollipop chart 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:

"lollipop chart of score per country, sorted"

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({"country": ["Norway", "Japan", "Canada", "Germany", "Brazil",
                               "India", "Kenya", "Peru", "Spain", "Vietnam"],
                   "score": [82, 77, 75, 74, 63, 58, 55, 61, 70, 66]}).sort_values("score")

fig, ax = plt.subplots(figsize=(6.4, 4))
ax.hlines(df["country"], 0, df["score"], color="lightgray", lw=2)
ax.plot(df["score"], df["country"], "o", ms=8)
ax.set_xlim(0, 100)
ax.set_xlabel("Score")
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