Repository navigation
Register the PyTES plot colours with matplotlib - #44
Merged
Merged
Conversation
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>
4 of 9 tasks
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
🚀 New features to boost your workflow:
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
src/pytes/thermal.mplstyleandthermal_dark.mplstyle(matplotlib finds"pytes.thermal"inside the package from 3.7), and the constantspytes.plotting.THERMALandTHERMAL_DARK."pytes.ember"(sequential) and"pytes.thaw"(diverging), plus_rreversals, registered whenpytes.plottingis imported. The data moves tosrc/pytes/colourmaps/;docs/design/colours/make_colourmaps.pynow writes there and reproduces both files exactly.import pytesstill does not import matplotlib (both tested).For review
pytes.emberin it would makeplt.style.usebreak wheneverpytes.plottinghad not been imported.pytes.prefix, as cmocean (cmo.) and Crameri (cmc.) do, as matplotlib's colourmap names are global.plotextra now needsmatplotlib>=3.7(it was unpinned).pybamm.QuickPlotignores the style until #5953 is released; the notebook says to passcolors=list(plotting.THERMAL)meanwhile.Changes
pytes.plotting:THERMAL,THERMAL_DARK,COLOURMAPS,register_colourmaps().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, andimport pytesdoes not import matplotlib.examples/plot_colours.ipynb, listed in the docs.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 andtab10, 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.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