collint
Detect and auto-fix visual collisions in matplotlib figures.
collint inspects a rendered figure and finds overlapping or clipped elements:
- text-text: tick labels, annotations, axis labels, titles, or legend text overlapping each other
- clipping: titles, axis labels, or tick labels cut off by the figure edge
- over-data: a legend or annotation covering plotted data
- element-element: overlapping subplots, colorbars, or a suptitle colliding with subplot titles
Detection is geometry-based over the rendered bounding boxes. The over-data case is confirmed by sampling the pixels underneath the decoration, so a legend placed over an empty region of a sparse plot is not falsely reported.
Install
Building requires a Rust toolchain (the core is a compiled extension).
pip install git+https://github.com/alejandro-soto-franco/collint
Or from a clone:
git clone https://github.com/alejandro-soto-franco/collint
cd collint
pip install .
Supported Python versions: 3.10 to 3.13.
Quick start
import matplotlib.pyplot as plt
import collint
fig, ax = plt.subplots(figsize=(2, 2))
ax.plot(range(100), range(100))
ax.set_xticks(range(0, 100))
ax.set_xticklabels([f"label{i}" for i in range(100)])
report = collint.check(fig)
print(report.has_collisions) # True
print(report.severity) # worst overlap fraction
print(report.to_json()) # machine-readable list
check never mutates the figure. It draws the figure on an Agg renderer if needed, so it works headless.
The report
check returns a CollisionReport:
report = collint.check(fig)
report.has_collisions # bool
report.collisions # list of Collision
report.severity # max severity across collisions (0.0 if none)
report.total() # summed severity
report.exit_code() # 0 if clean, 1 if any collision
report.by_type("text_text") # collisions of one kind
report.to_json() # JSON string
Each Collision carries the two elements involved:
for c in report.collisions:
print(c.kind) # "text_text" | "clipping" | "over_data" | "element_element"
print(c.a_role, c.a_id) # e.g. "tick-label", "axes0.tick.140..."
print(c.a_box) # (x0, y0, x1, y1) in display pixels
print(c.b_role, c.b_id)
print(c.b_box)
print(c.severity) # overlap fraction, or clip overhang in pixels
Auto-fixing
autofix tries to resolve collisions by applying matplotlib's own layout tools (constrained layout, tight layout, legend relocation, tick rotation), re-checking after each step and keeping a change only if it does not make things worse.
result = collint.autofix(fig)
print(result.actions) # e.g. ["constrained_layout"]
print(result.residual.has_collisions) # what remains after fixing
autofix reports exactly which steps it applied. It never returns a figure worse than the one it received.
Annotated overlay
Save a copy of the figure with every colliding region outlined in red:
from collint.overlay import render_overlay
report = collint.check(fig)
render_overlay(fig, report, "overlay.png")
The overlay is written to disk and the original figure is left unchanged.
Command line
Point the CLI at a Python file that defines a module-level fig. It prints the JSON report and exits non-zero when collisions are found, which makes it easy to gate a figure-generation pipeline.
collint myfigure.py
collint myfigure.py --overlay overlay.png
collint myfigure.py --no-pixels # skip pixel confirmation, geometry only
# myfigure.py
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([0, 1, 2], [0, 1, 0])
Exit code is 0 when the figure is clean and 1 when it has collisions.
pytest integration
Installing collint registers an assert_no_collisions fixture:
def test_my_plot_is_clean(assert_no_collisions):
fig = build_my_plot()
assert_no_collisions(fig)
The assertion fails with the JSON report when the figure has collisions.
savefig hook
Opt in to a warning every time a figure with collisions is saved:
import collint
collint.install()
fig.savefig("out.png") # warns if out.png has visual collisions
Configuration
Thresholds can be passed to check (and through autofix):
collint.check(
fig,
use_pixels=True, # confirm over-data collisions by sampling pixels
overlap_fraction=0.02, # minimum overlap (fraction of the smaller box)
clip_px=1.0, # minimum clip overhang in pixels
ink_fraction=0.05, # minimum data ink under a decoration to confirm over-data
)
Defaults ignore sub-pixel and antialiasing noise. Set use_pixels=False to run geometry-only detection, which is faster but reports any legend or annotation whose bounding box overlaps a data artist, even over empty regions.
Metadata
Release files for collint 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| collint-0.1.1.tar.gz | 19.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| collint-0.1.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| collint-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| collint-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| collint-0.1.1-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| collint-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 1.8 MB
Release files / collint-0.1.1.tar.gz
| Download URL | collint-0.1.1.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9ca314d5e9623d91a0930685ea0e7c738baa472ed5c12b9afb4ec803c8b6e31
|
|
BLAKE2b-256 checksum How to use checksums |
aa2753d1568058676de20f26d4631a901d91fff4f1ee79abee3a10e96c6c4c42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.
Transparency logRelease files / collint-0.1.1-cp310-abi3-win_amd64.whl
| Download URL | collint-0.1.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 239.2 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
9e1eb99d79241769532a9a1a0662978954c2ed7348755a68e3cc120fb5a73048
|
|
BLAKE2b-256 checksum How to use checksums |
50d1cde43dd33b0491e007df5d8c06f5066efb63bdd0d9de1db9fd6d779f9732
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.
Transparency logRelease files / collint-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | collint-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 415.7 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
dc040f84d3771f3b185594ba9366939a04d30f202568b3d5395304841b433566
|
|
BLAKE2b-256 checksum How to use checksums |
ab43ece2632efb054d4fdf8ae0284697a72d636084b2002a097c528256619b0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.
Transparency logRelease files / collint-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | collint-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 409.1 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
778c7d2b56ead702ef5f88323a0f34566886384395ab1e65e71a6fe120774e29
|
|
BLAKE2b-256 checksum How to use checksums |
8ea202c32bf5bc47da3c34ccf6a8270019159ea9ca2e15e97c46c23cb1a1c5e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.
Transparency logRelease files / collint-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | collint-0.1.1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 360.5 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5d0950b4737e2a951e091388bf76013dedb851dac468f55847bb5ae72803890e
|
|
BLAKE2b-256 checksum How to use checksums |
a8cba26dd56a7c637b0b2afa843bc609f69a1371c91adfeab43152b41e8769bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.
Transparency logRelease files / collint-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | collint-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 365.8 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
629d3c5bd027798a67428e020107fd84e41e95d238616faf4ed5729d721fdc41
|
|
BLAKE2b-256 checksum How to use checksums |
cb34457fc7f35376dfce9532da4aefe5592f8d8970d3efdf1d2a21da17011bd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.
Transparency log