Skip to main content

mpl-lego

PyPI Python License: MIT

mpl-lego is a small collection of reusable utilities for building and styling Matplotlib figures. It includes helpers for subplot labels, covariance ellipses, colorbars, legends, scatter plots, colors, and consistent axis styling.

Installation

Install the latest release from PyPI:

python -m pip install mpl-lego

mpl-lego supports Python 3.11 and newer and depends on Matplotlib and NumPy.

Quick start

import matplotlib.pyplot as plt
import numpy as np

from mpl_lego.axes import style_panel_axis
from mpl_lego.labels import apply_subplot_labels
from mpl_lego.scatter import tighten_scatter_plot

rng = np.random.default_rng(42)
observed = rng.normal(size=100)
predicted = observed + rng.normal(scale=0.35, size=100)

fig, ax = plt.subplots(figsize=(5, 5))
ax.scatter(observed, predicted, alpha=0.7)

style_panel_axis(ax, grid_axis="both")
tighten_scatter_plot(ax, color="black", linestyle="--")
apply_subplot_labels(ax, labels=["a"])

ax.set(xlabel="Observed", ylabel="Predicted")
fig.tight_layout()
plt.show()

Utilities

Module Helpers
mpl_lego.axes Style an axis or append a marginal axis.
mpl_lego.colorbar Map values to colors and append matched colorbars.
mpl_lego.colors Read the active color cycle and convert hex colors.
mpl_lego.ellipse Plot a two-dimensional covariance ellipse.
mpl_lego.labels Format labels, label subplots, and draw significance brackets.
mpl_lego.legend Build marker-based legend handles.
mpl_lego.scatter Equalize scatter-plot limits and add an identity line.
mpl_lego.style Enable Computer Modern and LaTeX text rendering when available.

All public functions include NumPy-style docstrings with their parameters and return values.

Development

Development uses uv for dependency management, virtual environments, testing, and package builds:

git clone https://github.com/pssachdeva/mpl-lego.git
cd mpl-lego
uv sync
uv run pytest
uv build

uv sync creates the project environment from uv.lock and installs the development dependency group automatically.

Three known regressions are tracked in the issue tracker. Their tests are marked as expected failures until the corresponding fixes land.

License

mpl-lego is distributed under the MIT License.

Download files

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

Source Distribution

mpl_lego-0.0.4.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

mpl_lego-0.0.4-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file mpl_lego-0.0.4.tar.gz.

File metadata

  • Download URL: mpl_lego-0.0.4.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mpl_lego-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2c0adda52c55c0878ee6b93a16aa9498b053a97297f6e7b974b8c59db3ad89d9
MD5 2766627e9614044cc51eaee92286521d
BLAKE2b-256 91dc9884f9a1b1f6096a8a15c1724c0e453ec93a03bb2e87d5d101adc1f9a187

See more details on using hashes here.

File details

Details for the file mpl_lego-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: mpl_lego-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mpl_lego-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9c8eead19ee47ace524e67b67cebcd24780087a56021a381d5bf017eaf9763e5
MD5 a0d0c5c3e526391f72a0b3e950804879
BLAKE2b-256 73f3528a66b79e47b604211e4bda9db087c11d3cdb33e5781f450042eda010ba

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 files

0.0.3

2 files

0.0.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page