Skip to main content

proteus-mpl

PROTEUS Thermocline matplotlib theme. Publication-grade figures whose colors, fonts, and surfaces match the slides, the website, and the docs.

Install

pip install proteus-mpl

From a checkout of the repository: pip install figures/proteus-mpl (or cd into the folder and pip install .).

The package needs Python 3.9 and matplotlib 3.8 or newer; CI runs the tests on the newest matplotlib and on matplotlib 3.8.0 with Python 3.9 and 3.11. The pytest plugin needs pytest 7 or newer.

Use

import proteus_mpl
proteus_mpl.use()           # light: Paper background — papers, light slides
# proteus_mpl.use("dark")   # dark: Void background — dark slides, hero figures
# proteus_mpl.use("white")  # light theme on pure white — journal pages

What you get

  • Cycles — both neutral-first, so a single-series plot draws in ink (light) / paper (dark) and magma stays a deliberate signal. Light (proteus_mpl.CYCLE, 9 colours): ink, magma, solar, verdant, ocean, tidal, outgassing, fog, azure; CVD worst-pair ΔE 15.7 (Machado 2009). Dark (CYCLE_DARK, 6 colours): paper, magma, solar, and light-safe tones; ΔE 16.8. Past the cycle, switch line style (solid/dashed/dotted/dash-dot) instead of adding hues, and keep legends on multi-series plots.
  • Accents — COLORS["solar"] (#E0A32E, the star) with COLORS["solar_deep"] (#C8860F) for gold fills or thin marks on light surfaces, and COLORS["verdant"] (#57A05C, the habitable endpoint).
  • Module domain colors — proteus_mpl.DOMAINS["interior"] etc, seven of them. Use these whenever a line is a module (SPIDER output → interior red, MORS → solar gold, Morrigan → accretion clay #A38F7A). Stable across every paper, talk, and diagram. Three of them are light in tone and thin out on a pale page: stellar gold at 2.0:1, atmosphere blue at 2.5:1, and accretion clay at 2.8:1 against Paper. Give those a legend rather than leaning on the hue for small marks.
  • Colormaps — proteus (sequential, Void→Paper; default for imshow / pcolormesh; the one ramp that survives greyscale reproduction), proteus_div (diverging, light midpoint — print-safe for anomalies/residuals), proteus_phase (the brand ramp, magma→void→ocean, dark midpoint — hero figures and dark slides). _r reversals registered.
  • Type — Instrument Sans labels, Spline Sans Mono available for ticks via fontfamily="Spline Sans Mono"; titles bold, left-aligned. The OFL brand fonts ship inside the package and register automatically on use().
  • Publication settings — 300 dpi savefig, tight bbox, TrueType embedding (fonttype 42), text-as-paths SVG. Prefer fig.savefig("fig.pdf").

The cycle on each surface

light cycle dark cycle

Regenerate with python examples/cycle.py.

Validation plots

proteus_mpl.validation.save writes one validation plot as a light and a dark file. With the same matplotlib and Pillow versions the same figure gives the same bytes, so the files can be committed next to the docs:

from proteus_mpl.validation import save

def make_figure():
    fig, ax = plt.subplots()
    ax.plot(t, model, label="model")
    ax.plot(t_ref, ref, "o", label="reference")
    return fig

save(make_figure, "melt_fraction", "docs/assets/validation")              # melt_fraction.svg, melt_fraction_dark.svg
save(make_heatmap, "phase_map", "docs/assets/validation", kind="map")     # phase_map.avif, phase_map_dark.avif

make_figure is called once per theme, so it must create the figure itself. Line and point plots (kind="line") are SVG with text as paths, no date, a fixed creator and a fixed hash salt; maps and heatmaps (kind="map") are AVIF at quality 80 with fixed encoder settings and need Pillow with AVIF support (pip install "proteus-mpl[validation]"). A file above 60 000 B (validation.MAX_BYTES) is refused with its name and size, and nothing is written; a dense field belongs in kind="map", while a small element drawn with rasterized=True can stay in an SVG as long as the file is under the cap. A name must not end in _dark, the suffix of the dark file. The test id and the command that makes the plot again go into the file metadata.

The package registers a pytest plugin, proteus_mpl.pytest_plugin, which needs pytest 7 or newer and loads by itself; a conftest does not need to list it. A test asks for the validation_plot fixture and calls it with the factory and a name:

@pytest.mark.reference_pinned
def test_melt_fraction(validation_plot):
    t, model = run_case()
    assert np.allclose(model, ref, rtol=1e-3)
    validation_plot(lambda: plot_case(t, model), "melt_fraction")

Without the option the fixture checks the plot against the committed pair:

  • It calls the factory, renders both themes in memory, applies the size cap and writes nothing, so each run of the test pays for two renders (a smooth 200 x 200 map takes about 0.6 s on an arm64 Mac, most of it in rasterizing and encoding the two files).
  • It compares a data summary of the figure with the summary stored in both committed files in docs/assets/validation. The summary holds, per axes, inset axes and parasite axes, the axis scales, the category names of categorical axes, and the point count and the min, max, mean and a ramp-weighted mean of each coordinate of every line, every collection (offsets of scatter points, hexbins, quivers and barbs, mesh coordinates, vertices of fills, error bars and contours; labelled line contours from their contour generator, so label gaps, figure size, font size and dpi do not count; a labelled contour set without one, such as one built from segments, is read from its drawn paths, where inline label gaps count) and its colour values (in log10 under a log norm, and the norm scale of each is kept; and the vectors of quivers and barbs, masks kept), the corners of all patches except annotation arrows (bars, histograms, ax.arrow), and every image with its origin and extent.
  • Coordinates are in axis units; on a log axis the statistics are of the log10 of the values (values at or below zero are left out), and symlog and logit axes stay linear. The ramp weight runs from -1 at the first point to 1 at the last, so a reversed series is found, and the order of scatter points and bars counts; a change inside a series that leaves all four statistics within the tolerance is not found.
  • A value passes within validation.SUMMARY_RTOL (1e-6) of the range of the committed coordinate, or of a tenth of its largest magnitude when that is larger (on a log axis and under a log norm, of the range of the log10 values or 0.1 decade when that is larger, so the tolerance is at least 1e-7 decade at any magnitude: 1 and 1 + 1e-12 agree, 1 and 1 + 1e-5, 4.3e-6 decade apart, differ); counts, axis and norm scales and category names must match. Large offsets set the floor: on a date axis near 2024 it is about 170 s. A coordinate that is round-off noise, such as a residual near 1e-16, differs between machines on its own scale; plot it with a floor well above the noise, such as np.maximum(residual, 1e-12) for a residual near 1e-16 on a log axis, or leave it out.
  • Not compared: 3D and secondary axes, the base of a log scale, axis labels, limits, text, colours, artist transforms, annotation arrows, the shapes of offset markers and the interior cell edges of pcolorfast and NonUniformImage images; a colorbar is compared as an axes, so a colormap with another number of colours changes it.
  • Which artists a plot type makes depends on the matplotlib version, so make the pairs with the matplotlib the repository's CI installs, and make them again after an upgrade. The summary adds about 90 to 170 B per line and 90 B per axes to each file, which counts toward the size cap.
  • A factory whose light and dark figures hold different data is refused. A missing committed file, a file committed under a name that differs only in case (the message asks for a git mv), a file that is not a whole SVG or AVIF (empty, cut, an LFS pointer), an unreadable summary or a summary that differs fails the test with a hint to make the pair again. A committed file without a summary of the current format passes with a warning, which fails the test in a repository that sets filterwarnings = error.
  • A test that takes validation_plot and passes without calling it fails at teardown.

With the option the fixture writes and does not compare; on a case-insensitive file system it renames a committed file whose name differs only in case. pytest -m reference_pinned --validation-plots writes every plot to docs/assets/validation under the pytest rootdir; --validation-plots=DIR writes to another folder, relative to the rootdir. A bare --validation-plots followed by a word, which it would read as its folder, is refused, also from addopts or an @argfile, so write --validation-plots=DIR (always in addopts and PYTEST_ADDOPTS) or put the option after the test paths. A plot name used twice for one kind in a session is refused, with or without the option, so a parametrized test needs one name per parameter, such as f"case_{param}"; a rerun of the same test may use its names again. The reference_pinned marker belongs to the repository that runs the tests, which registers it in its pytest configuration. Under pytest-xdist each worker keeps its own list of names, so a name repeated in tests that run on different workers is not caught. The stamped command names a folder given with --validation-plots=DIR.

Conventions

  • Size figures at final printed size (A&A column ≈ 3.5 in) and keep default font sizes — never shrink a huge figure down.
  • Light figures on light surfaces, dark figures on dark — no visible card.
  • Journal white pages: use("white"), or transparent=True at savefig.
  • Magma is the hot signal: reserve it for the series you want the room to look at. Everything else starts from Ocean.

Metadata

Release files for proteus-mpl 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for proteus-mpl 1.5.0
File Size Uploaded Provenance Actions
proteus_mpl-1.5.0.tar.gz 215.6 kB With provenance Details for proteus_mpl-1.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for proteus-mpl 1.5.0
File Interpreter ABI Platform Actions
proteus_mpl-1.5.0-py3-none-any.whl Python 3 none any Details for proteus_mpl-1.5.0-py3-none-any.whl

Total release size: 410.0 kB

Release files / proteus_mpl-1.5.0.tar.gz

Download URL proteus_mpl-1.5.0.tar.gz
Size 215.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8a5436dd6badcd67b483d8a248d6627b6b483fcd4006848737d47bb15fcf258d
BLAKE2b-256 checksum
How to use checksums
88920a74d798b480ad6f18d0da75859970bb1a8aca30ff6a37893dc3b97df632
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 24, 2026.

Transparency log

Release files / proteus_mpl-1.5.0-py3-none-any.whl

Download URL proteus_mpl-1.5.0-py3-none-any.whl
Size 194.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58da3a9d461234b578d8cc3c8b3fe03c698ad402418bebc202411b3b95734099
BLAKE2b-256 checksum
How to use checksums
fdc7aa8c8117b37cab8b746aea5a1d290d2927bdc607c440df8ddef42bc65cce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 24, 2026.

Transparency log

Security for proteus-mpl 1.5.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for proteus_mpl-1.5.0.tar.gz

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 Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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