Skip to content

Register the PyTES plot colours with matplotlib - #44

Merged
brosaplanella merged 5 commits into
mainfrom
design-plot-colours
Oct 30, 2026
Merged

brosaplanella merged 5 commits into
mainfrom
design-plot-colours

Conversation

@brosaplanella

@brosaplanella brosaplanella commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Registers the PyTES plot colours (DESIGN D15) so they can be used now, without making them the default. Part of #43: the default waits for PyBaMM (pybamm-team/PyBaMM#5953, then a plot-style hook tracked in #39).

What users get

import matplotlib.pyplot as plt
import pytes.plotting

plt.style.use("pytes.thermal")       # or "pytes.thermal_dark", after a dark style
ax.pcolormesh(t, z, T, cmap="pytes.ember")
ax.pcolormesh(t, z, T, cmap="pytes.thaw", norm=CenteredNorm(vcenter=T_melt))
  • Colour cycles PyTES Thermal and PyTES Thermal (dark): the style sheets src/pytes/thermal.mplstyle and thermal_dark.mplstyle (matplotlib finds "pytes.thermal" inside the package from 3.7), and the constants pytes.plotting.THERMAL and THERMAL_DARK.
  • Colourmaps "pytes.ember" (sequential) and "pytes.thaw" (diverging), plus _r reversals, registered when pytes.plotting is imported. The data moves to src/pytes/colourmaps/; docs/design/colours/make_colourmaps.py now writes there and reproduces both files exactly.
  • Nothing changes matplotlib's defaults, and import pytes still does not import matplotlib (both tested).

For review

  • Merging adopts thaw and PyTES Thermal (dark). They were "proposed, for the maintainer's review" in D15; this PR drops that wording.
  • The style sheets set only the colour cycle. A style sheet cannot register a colourmap, so naming pytes.ember in it would make plt.style.use break whenever pytes.plotting had not been imported.
  • Colourmap names carry a pytes. prefix, as cmocean (cmo.) and Crameri (cmc.) do, as matplotlib's colourmap names are global.
  • The plot extra now needs matplotlib>=3.7 (it was unpinned).
  • pybamm.QuickPlot ignores the style until #5953 is released; the notebook says to pass colors=list(plotting.THERMAL) meanwhile.

Changes

  • pytes.plotting: THERMAL, THERMAL_DARK, COLOURMAPS, register_colourmaps().
  • Tests in tests/toolkit/test_plotting.py: the style sheets match the constants, the maps are registered and reversible, registering twice is harmless, ember's lightness rises and passes through the brand orange, thaw's lightness peaks at the centre and is about symmetric, matplotlib's defaults are unchanged, and import pytes does not import matplotlib.
  • Example notebook examples/plot_colours.ipynb, listed in the docs.
  • Documentation page docs/plot_colours.md ("Plot colours", in the top-level navigation): how to use the colours and the rationale (hot-then-cold order, the colour-vision checks and comparison with Okabe–Ito, Tol and tab10, perceptual uniformity and the comparison with inferno, cmocean and Crameri, and why they are not the default yet). Swatches and colourmap bars are CSS (docs/_static/pytes.css), generated from the shipped values.
  • DESIGN D15: how the colours are available now, and how they become the default; brand guide updated.
  • Changelog fragment 44.feature.md.

Locally: 767 fast tests pass, the notebook passes under nbmake, ruff is clean, and the docs build. The wheel contains the style sheets and the colourmap data.

🤖 Generated with Claude Code

brosaplanella and others added 2 commits October 28, 2026 22:28
Choose the colour cycle "PyTES Thermal" and the sequential colourmap
"ember", both led by the brand orange and checked under simulated
protan, deutan and tritan vision. Propose, for review, the diverging
colourmap "thaw" and the dark-background cycle "PyTES Thermal (dark)".

Add docs/design/colours/ with the generator script and the 256 values
of each colourmap, and list the colours in the brand guide. Adoption in
pytes.plotting waits for pybamm-team/PyBaMM#5953 and a release (#43).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ship the colour cycles PyTES Thermal and PyTES Thermal (dark) as the
matplotlib styles "pytes.thermal" and "pytes.thermal_dark" and as
pytes.plotting.THERMAL and THERMAL_DARK, and register the colourmaps
"pytes.ember" and "pytes.thaw" (and their reversals) when
pytes.plotting is imported. Nothing becomes the default: that waits for
PyBaMM (#43, #39). import pytes still does not import matplotlib.

Move the colourmap data into src/pytes/colourmaps/, where the generator
now writes it. The plot extra needs matplotlib 3.7 or later, which finds
styles inside a package. Add tests, the example notebook
plot_colours.ipynb and a changelog fragment, and record in DESIGN D15
how the colours are available now and how they become the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@read-the-docs-community

read-the-docs-community Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff            @@
##              main       #44   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           47        47           
  Lines         1749      1768   +19     
  Branches       155       157    +2     
=========================================
+ Hits          1749      1768   +19     
Files with missing lines Coverage Δ
src/pytes/plotting.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

brosaplanella and others added 3 commits October 30, 2026 09:20
Explain the colour cycles and colourmaps for users: how to use them,
why they lead with the PyTES orange, how they were checked for
colour-vision deficiency and against the best-known palettes, why the
colourmaps are perceptually uniform, and why they are not the default
yet. Swatches and colourmap bars are drawn in CSS from the shipped
values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TwoSlopeNorm stretched each half of thaw over its own range, 28 K below
the melting temperature and 10 K above it in the example, so a kelvin
looked 2.8 times bigger on the hot side and the colourbar ticks were
unevenly spaced. CenteredNorm keeps the range symmetric, so the map's
equal steps hold on both sides. Say when TwoSlopeNorm still fits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A small script puts a square of the colour before every inline code
that is a hex colour, such as `#E8590C`, as code editors do. The
swatches on the plot colours page are skipped, as they already show
their colour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brosaplanella
brosaplanella merged commit 6910f3f into main Oct 30, 2026
20 checks passed
@brosaplanella
brosaplanella deleted the design-plot-colours branch October 31, 2026 16:26
@brosaplanella brosaplanella mentioned this pull request Nov 2, 2026
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant