To label a Matplotlib bar chart with its values, pass the bars returned by ax.bar() to ax.bar_label(). ax.bar_label(bars, fmt="{:,.0f}", padding=3) writes each value just above its bar with a thousands separator. It works the same for ax.barh(), grouped bars, and bars drawn by pandas or Seaborn.
Quick Example
import matplotlib.pyplot as plt
import numpy as np
exhibits = ["Dinosaurs", "Space", "Oceans", "Ancient Egypt", "Gems", "Robots"]
visitors = np.array([41250, 36800, 29400, 25100, 12700, 18350])
fig, ax = plt.subplots(figsize=(8, 4.5), layout="constrained")
bars = ax.bar(exhibits, visitors, color="#3d5a80")
ax.bar_label(bars, fmt="{:,.0f}", padding=3)
ax.set_ylabel("Visitors in 2025")
ax.margins(y=0.1)
plt.show()

ax.margins(y=0.1) adds 10% headroom so the tallest label isn't cut off at the top of the axes. ax.bar_label was added in Matplotlib 3.4; for older versions, see the ax.text fallback at the end.
bar_label parameters
| Parameter | What it does |
|---|---|
container |
The bars: what ax.bar() or ax.barh() returns, or an item of ax.containers |
labels=None |
A list of strings to use instead of the values |
fmt="%g" |
A format string ("%.1f" or "{:,.0f}") or a function that takes the value |
label_type="edge" |
"edge" puts the label at the end of the bar, "center" in the middle |
padding=0 |
Distance from the bar end in points. Negative values move it inside. Since 3.11 it also accepts one value per bar |
fontsize, color, fontweight, rotation, ... |
Passed through to the text. ha and va aren't allowed because bar_label aligns the labels itself |
{}-style format strings and functions for fmt need Matplotlib 3.7 or later. Before that, only %-style strings like "%.1f" work.
Format the labels with fmt
fmt takes any str.format pattern, or a function for anything a pattern can't do. These four panels draw the same bars with different formats:
formats = {
'fmt="{:,.0f}"': "{:,.0f}",
'fmt="{:.2e}"': "{:.2e}",
"fmt=lambda v: f\"{v / 1000:.1f}k\"": lambda v: f"{v / 1000:.1f}k",
'fmt="{:.0%}" on shares': "{:.0%}",
}
share = visitors / visitors.sum()
fig, axs = plt.subplots(2, 2, figsize=(10, 6.5), layout="constrained")
for ax, (title, fmt) in zip(axs.flat, formats.items()):
values = share if "%" in title else visitors
bars = ax.bar(exhibits, values, color="#98c1d9")
ax.bar_label(bars, fmt=fmt, padding=2, fontsize=9)
ax.set_title(title, family="monospace", fontsize=10)
ax.tick_params(axis="x", labelsize=8)
ax.margins(y=0.15)
plt.show()

A lambda is the easy way to get units like k or M, or currency with a symbol (fmt="${:,.0f}" also works). For the percentages, the bars are each exhibit's share of the total, so the "{:.0%}" pattern multiplies by 100 and adds the sign.
Custom label text with labels=
When the label needs information that isn't the bar's height, build the strings yourself and pass them as labels. An empty string skips a bar:
change = np.array([0.08, 0.21, -0.04, 0.02, -0.11, 0.35])
labels = [f"{v / 1000:.1f}k\n{c:+.0%}" if abs(c) >= 0.05 else f"{v / 1000:.1f}k"
for v, c in zip(visitors, change)]
fig, ax = plt.subplots(figsize=(8, 4.5), layout="constrained")
bars = ax.bar(exhibits, visitors, color="#3d5a80")
ax.bar_label(bars, labels=labels, padding=3, fontsize=9)
ax.set_ylabel("Visitors in 2025")
ax.set_title("Visitors, with change vs 2024 where it moved 5% or more", loc="left")
ax.margins(y=0.15)
plt.show()

labels must have one entry per bar, in the same order as the bars.
Put the labels inside the bars
There are two ways to move labels inside. label_type="center" puts them in the middle of each bar. A negative padding with label_type="edge" keeps them at the end of the bar but tucks them inside it.
fig, axs = plt.subplots(1, 2, figsize=(10, 4.2), sharey=True, layout="constrained")
for ax in axs:
ax.tick_params(axis="x", rotation=30)
bars = axs[0].bar(exhibits, visitors, color="#ee6c4d")
axs[0].bar_label(bars, fmt="{:,.0f}", label_type="center", color="white", fontsize=9)
axs[0].set_title('label_type="center"', family="monospace", fontsize=10)
bars = axs[1].bar(exhibits, visitors, color="#ee6c4d")
axs[1].bar_label(bars, fmt="{:,.0f}", padding=-14, color="white",
fontsize=9, fontweight="bold")
axs[1].set_title("padding=-14", family="monospace", fontsize=10)
plt.show()

White labels inside the bars need a dark enough bar color to read. "center" is also the one to use for stacked bars, where each segment gets its own label; see stacked bar charts with labels.
Labels on horizontal bars
bar_label works the same way on ax.barh(). The labels go to the right of each bar, so give the x-axis some room with ax.margins(x=...):
order = np.argsort(visitors)
fig, ax = plt.subplots(figsize=(8, 4), layout="constrained")
bars = ax.barh(np.array(exhibits)[order], visitors[order], color="#293241")
ax.bar_label(bars, fmt="{:,.0f}", padding=4)
ax.margins(x=0.12)
ax.spines[["top", "right", "bottom"]].set_visible(False)
ax.set_xticks([])
plt.show()

With the values printed on the bars, the x-axis is redundant, so this chart drops it. The sorted horizontal bar chart post goes further with this style.
Labels on negative bars
For bars below zero, label_type="edge" puts the label under the bar instead of above it, so positive and negative values both read outward from zero. A + in the format string shows the sign on both:
colors = np.where(change >= 0, "#2a9d8f", "#e76f51")
fig, ax = plt.subplots(figsize=(8, 4.5), layout="constrained")
bars = ax.bar(exhibits, change, color=colors)
ax.bar_label(bars, fmt="{:+.0%}", padding=3)
ax.axhline(0, color="black", linewidth=0.8)
ax.set_ylabel("Change in visitors vs 2024")
ax.margins(y=0.15)
plt.show()

Robots grew the most (+35%) and Gems fell the most (-11%).
Label every bar in a grouped bar chart
Each call to ax.bar() makes one container, and ax.containers holds all of them. Loop over it to label every group:
weekday = np.array([18.2, 14.9, 13.1, 9.8, 5.2, 8.9])
weekend = np.array([23.0, 21.9, 16.3, 15.3, 7.5, 9.5])
x = np.arange(len(exhibits))
width = 0.4
fig, ax = plt.subplots(figsize=(9, 4.5), layout="constrained")
ax.bar(x - width / 2, weekday, width, label="Weekday", color="#98c1d9")
ax.bar(x + width / 2, weekend, width, label="Weekend", color="#3d5a80")
for container in ax.containers:
ax.bar_label(container, fmt="{:.1f}", padding=2, fontsize=9)
ax.set_xticks(x, exhibits)
ax.set_ylabel("Visitors (thousands)")
ax.legend(loc="upper right")
ax.margins(y=0.12)
plt.show()

The same loop labels bars drawn by df.plot.bar() in pandas and by sns.barplot() in Seaborn, since both draw onto ax and leave their containers there. The Seaborn bar labels post has a Seaborn version.
Bars with error bars
If the bars have error bars (yerr= or xerr=), bar_label puts each label past the end of the error bar, so the label and the error bar don't overlap. Nothing extra is needed:
fig, ax = plt.subplots(figsize=(8, 4.5), layout="constrained")
bars = ax.bar(exhibits, weekend, yerr=[2.1, 3.4, 1.8, 2.6, 0.9, 1.5],
capsize=4, color="#e0fbfc", edgecolor="#3d5a80")
ax.bar_label(bars, fmt="{:.1f}", padding=4)
ax.set_ylabel("Weekend visitors (thousands)")
ax.margins(y=0.12)
plt.show()

Different padding for each bar (Matplotlib 3.11)
Since Matplotlib 3.11, padding also accepts one value per bar, which helps when one label collides with something such as a reference line. For example, ax.bar_label(bars, padding=[3, 3, 14, 3, 3, 3]) lifts only the third label. On older versions, keep the list of labels that bar_label returns and change one label's offset in points: labels = ax.bar_label(bars, padding=3), then labels[2].xyann = (0, 14).
Why is the top label cut off?
bar_label doesn't change the axis limits, so the label above the tallest bar can run past the top of the axes. Add headroom with ax.margins(y=0.1) (or x= for horizontal bars), or set the limit directly with ax.set_ylim(top=...). See setting axis limits.
Before Matplotlib 3.4: label bars with ax.text
On Matplotlib older than 3.4 there's no bar_label. Loop over the bars and place the text yourself:
fig, ax = plt.subplots(figsize=(8, 4.5), layout="constrained")
bars = ax.bar(exhibits, visitors, color="#3d5a80")
for bar in bars:
height = bar.get_height()
ax.text(bar.get_x() + bar.get_width() / 2, height, f"{height:,.0f}",
ha="center", va="bottom")
plt.show()
This draws the same labels as the Quick Example, without the padding. On any current version, use bar_label, which also handles negative bars, horizontal bars, and error bars.