skillfed

matplotlib-scalebar

Artist for matplotlib to display a scale bar

matplotlib-scalebar v0.9.0 148.9K downloads/30d#11,016 on PyPI171
Permissive license DORMANT released

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-scalebar

uv

uv add matplotlib-scalebar

poetry

poetry add matplotlib-scalebar

Installing 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

Development Status :: 5 - Production/StableFramework :: MatplotlibIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Visualization

Tags

matplotlib scale barimage calibration barmicron bar matplotlibpixel size visualizationscientific image annotation
scientific-visualizationimage-annotation

More Visualization packages