Skip to main content

Lint Python visualizations for common misleading patterns.

Project description

vizlint

Super-fast linting for Python visualizations so misleading charts never leave your notebook.

PyPI License: MIT

Overview

vizlint inspects Matplotlib figures for easy-to-miss quality problems such as truncated bar charts or missing labels. Use it directly from Python, in a notebook, or via a CLI that runs headless by default (Agg backend) so it is safe in CI.

Features

  • Single-call API: vizlint.lint(fig) returns a Report you can print or serialize.
  • Matplotlib adapter included; install vizlint[mpl] for the plotting extra.
  • CLI that executes your plotting script, lints every open figure, and supports per-rule toggles via --disable.
  • Notebook helper vizlint.lint_last() to lint the figure you just rendered.
  • Default rules catch truncated bar charts, unlabeled axes, stretched ranges, and missing titles.

Install

pip install vizlint
pip install "vizlint[mpl]"  # Matplotlib extra

Quickstart (Python)

import matplotlib.pyplot as plt
import vizlint

fig, ax = plt.subplots()
ax.bar(["A", "B"], [101, 103])
ax.set_ylim(100, 104)

report = vizlint.lint(fig)
print(report.summary())

Example output

vizlint report:
- WARN [bar_zero_baseline] Bar chart y-axis does not include zero, which can exaggerate differences between bars. Hint: Consider starting the y-axis at zero or switch to a different chart type if you need to zoom in.

CLI usage

The CLI runs your plotting script, forces the Agg backend for headless safety, and lints every open figure:

vizlint path/to/script.py

Disable individual rules by name (rule function names) without editing code:

vizlint path/to/script.py --disable axis_labels_missing --disable bar_zero_baseline

Exit code is 0 when all figures are clean, 1 when any warning is emitted, and 2 if the user script or Matplotlib import fails.

Jupyter / notebooks

Lint the most recently drawn Matplotlib figure from a notebook cell:

import vizlint

# after plotting
report = vizlint.lint_last()
display(report.summary())

Current checks

  • bar_zero_baseline (warning) – Flags bar charts whose y-axis range excludes zero, making differences look larger than they are.
  • axis_labels_missing (warning) – Reports charts missing an x-axis label, y-axis label, or both.
  • axis_range_overexpanded (warning) – Detects y-axes that span far beyond the data range, which can minimize apparent variation.
  • title_missing (warning) – Reminds you to add a descriptive chart title to aid quick interpretation.

Configuration & custom rules

vizlint.lint(fig, rules=None) uses vizlint.rules.DEFAULT_RULES when rules is None. Pass your own list to customize behavior:

from vizlint import lint
from vizlint.rules import DEFAULT_RULES, axis_labels_missing

custom = [rule for rule in DEFAULT_RULES if rule is not axis_labels_missing]
report = lint(fig, rules=custom)

# Structured output (e.g., for JSON APIs)
payload = report.to_dict()

In the CLI, use --disable rule_name to skip specific default checks. For richer integrations, the Report object exposes .issues, .is_clean(), .summary(), and .to_dict().

Development

git clone https://github.com/jaeday1212/vizlint.git
cd vizlint
pip install -e .
pip install -e .[mpl]
python -m pytest

You can also run the CLI locally via python -m vizlint.cli path/to/script.py.

Roadmap

  • Add more visualization rules (e.g., stacked bars, dual-axis charts).
  • Support additional backends beyond Matplotlib.
  • Provide optional JSON output mode in the CLI.
  • Deepen notebook widgets for inline remediation hints.

Looking Ahead

Upcoming explorations include native adapters for Seaborn and Plotly plus hooks that let LLM-based assistants recommend fixes based on the Report output.

Contributing

Bug reports and pull requests are welcome. Please run python -m pytest before submitting and keep changes focused with clear descriptions.

License

vizlint is available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vizlint-0.2.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vizlint-0.2.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file vizlint-0.2.1.tar.gz.

File metadata

  • Download URL: vizlint-0.2.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for vizlint-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b0a4260522362b912ce315461044f3f22bc59094ddd69a9a7707448e498b19cd
MD5 905c0c2d26937158278243205e642488
BLAKE2b-256 5421db8bd5949c971b7810b7f829e7bd41a49c187da48f58682c615fa18f53cd

See more details on using hashes here.

File details

Details for the file vizlint-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: vizlint-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for vizlint-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f471f1c36287edffdb0505d329f2df0265e525a358c51480adb34382422640fd
MD5 0e8d57d4e11d0f55ea7cfbf6b5b88bf0
BLAKE2b-256 c10d57daad940341091d3b960c9e84f462d801d52f1d011a110c2d666daa0641

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page