matplotlib-scalebar
Artist for matplotlib to display a scale bar
What it is and what it does
matplotlib-scalebar extends matplotlib with a new artist class that overlays a scale bar on plots, primarily for displaying calibrated images via imshow(). You specify the pixel size (dx) and its units, and the package automatically renders an appropriately-scaled bar with optional labels, customizable positioning, and support for multiple unit systems (SI length, imperial, astronomical, angle, pixel-based, and reciprocal dimensions).
The scale bar integrates directly into matplotlib's artist system—you create a ScaleBar object, add it to an axes via add_artist(), and configure appearance through constructor arguments or matplotlibrc settings. It's designed for scientific imaging workflows where pixel dimensions are known and need visual representation on output plots or saved figures.
Use it for:
- Annotate microscopy images with a calibrated scale bar showing micrometers or nanometers.
- Display geospatial plots with distance references using UTM or lat/lon coordinate systems.
- Save publication-quality scientific figures with scale information preserved at original resolution.
- Add dimension references to satellite or aerial imagery without modifying the underlying data.
- Customize scale bar appearance to match journal or presentation requirements.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds a matplotlib artist that renders a calibrated scale bar on images, with customizable size, position, units, and appearance.
Yes. Low install friction, no security issues, permissive license, and recent maintenance make it a safe choice. Install if you regularly plot calibrated images and need a standard way to display scale information; skip if you never use imshow() or prefer manual annotation.
Install
matplotlib-scalebar on PyPI
pip
pip install matplotlib-scalebaruv
uv add matplotlib-scalebarpoetry
poetry add matplotlib-scalebarInstalling matplotlib-scalebar
Before you install
Low friction: single runtime dependency on matplotlib, pure Python wheel. Repository shows recent activity (last commit 2025-01-17) and stable release history since 2016, though marked dormant.
License in practice
Permissive license (BSD) allows use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install matplotlib-scalebar
import matplotlib.pyplot as plt
from matplotlib_scalebar.scalebar import ScaleBar
fig, ax = plt.subplots()
ax.imshow(image_array, cmap="gray")
scalebar = ScaleBar(0.08, "cm", length_fraction=0.25)
ax.add_artist(scalebar)
plt.show()
Requires matplotlib as a runtime dependency.
Verify before relying
- Whether the package supports all matplotlib backends equally or has known limitations with certain renderers.
- Performance characteristics when rendering scale bars on very large images or in animation loops.
- Full extent of customization options beyond those shown in the provided examples.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — matplotlib |
| Maintenance | dormant — 574 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 148,860/month — #11,016 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: matplotlib_scalebar-0.9.0-py3-none-any.whl
Keywords: bar, matplotlib, micron, scale
Tags
More Visualization packages
matplotlib creates static, animated, and…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
plotlyPlotly is an interactive, browser-based…
permissive · top 1,000 on PyPI
graphvizGenerates DOT language source code for graph…
permissive · top 1,000 on PyPI
streamlitStreamlit transforms Python scripts into…
permissive · top 1,000 on PyPI
leatherLeather is a lightweight Python charting…
permissive · top 1,000 on PyPI
koreanize-matplotlibAutomatically configures matplotlib to display…
permissive · top 15,000 on PyPI
progressbar33Displays text-based progress bars in the…
unclear · top 15,000 on PyPI
lovelyplotsLovelyPlots provides matplotlib style sheets…
permissive · top 15,000 on PyPI
palettablePalettable provides a library of color palettes…
permissive · top 5,000 on PyPI
cmcrameriProvides perceptually uniform colormaps by…
permissive · top 15,000 on PyPI
histHist provides a user-friendly interface for…
permissive · top 15,000 on PyPI
cmapcmap provides a collection of scientific…
permissive · top 15,000 on PyPI
japanize-matplotlibEnables matplotlib to display Japanese text in…
permissive · top 15,000 on PyPI