Plot guides › Chart types

Horizontal bar chart

Turning a bar chart sideways gives long category names room to breathe and makes ranked lists easy to scan from top to bottom.

Example horizontal bar 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:

"horizontal bar chart of the 10 most common answers, largest at the top"

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({
    "answer": ["Not enough time", "Too expensive", "Hard to learn",
               "Missing features", "Poor documentation", "No team buy-in",
               "Security concerns", "Other"],
    "count": [142, 118, 97, 76, 64, 41, 33, 20],
}).sort_values("count")

fig, ax = plt.subplots(figsize=(6.4, 4))
ax.barh(df["answer"], df["count"], color="C0")
ax.set_xlabel("Respondents")
ax.bar_label(ax.containers[0], padding=3)
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