Install & Compatibility
Where this runs
tested against v0.8.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 2.744s · 179MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 7.7s · import 2.666s · 171MB
182MB installed
● package 182MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
labelLines
✓ from labellines import labelLines
✗ import labelLines
Module name is 'labellines' (no spacing), function is labelLines.
labelLine
✓ from labellines import labelLine
✗ from labellines import label_lines
Function is camelCase, not snake_case.
Basic example: plot three lines and label them with automatic positioning.
import matplotlib.pyplot as plt
import numpy as np
from labellines import labelLines
x = np.linspace(0, 1, 100)
fig, ax = plt.subplots()
for i in range(1, 4):
ax.plot(x, x**i, label=f'$x^{i}$')
labelLines(ax.get_lines())
plt.show()
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'labellines'
Attempted import with wrong name (e.g., 'matplotlib_label_lines' or 'labellines' misspelled).
fixInstall via pip and use: from labellines import labelLines
ImportError: cannot import name 'labelLines' from 'labellines'
Older version of the library (before 0.6.0) used a different function name or the module is not installed correctly.
fixUpgrade to latest version: pip install --upgrade matplotlib-label-lines
KeyError: 'label' when calling labelLines
One or more lines in the collection do not have a label set (label is empty or None).
fixSet label for each line: plt.plot(x, y, label='my line') or pass lines with labels only.
Upgrade
Version history
0.8.1latest on PyPI · released Apr 25, 2025
Audit
Dependencies
matplotlibrequiredRequired for plotting
numpyrequiredUsed internally for coordinate handling