Plot guides › Chart types

Histogram

A histogram counts how many values fall into each bin, showing the shape of a distribution: its centre, spread, skew and any second peak.

Example histogram made with matplotlib
Rendered from the code below, with example data.

When to use it

Watch out: The bin width changes the story. Try a few, or use a KDE or ECDF to avoid the choice.

Ask for it in pltchat

Upload your file and type something like:

"histogram of response time with 40 bins, overlay the two app versions"

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 numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(6)
v1 = rng.lognormal(5.0, 0.4, 2000)
v2 = rng.lognormal(4.8, 0.35, 2000)

fig, ax = plt.subplots(figsize=(6.4, 4))
bins = np.linspace(0, 400, 41)
ax.hist(v1, bins=bins, alpha=0.6, label="v1")
ax.hist(v2, bins=bins, alpha=0.6, label="v2")
ax.set_xlabel("Response time (ms)")
ax.set_ylabel("Requests")
ax.legend()
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