Repository navigation
feat(plot)!: take plot colours from the DSE design tokens - #121
Merged
Merged
Conversation
Vendor the research colours generated by dsegroup/apps-common and pin them by hash, with a test that fails if the copy changes. The plot styles take their categorical, ordered and continuous colours and their text, line and background roles from it: - CHART_COLOURS (chart-1 to chart-6) is the default colour cycle and categorical_palette's default. - sequential_palette and diverging_palette return three to five ordered steps, each reaching 3:1 against the background. - SEQUENTIAL_CMAP and DIVERGING_CMAP are registered as dse_sequential and dse_diverging; the sequential scale is the default image.cmap, and plot_heatmap can centre the diverging scale. BREAKING CHANGE: categorical_palette(n) raises ValueError for more than six series unless a matplotlib palette is named, the default colour cycle and image colormap change, and TEXT_COLOUR and LINE_COLOUR take the design roles. The COLOUR_* hues are deprecated: blue, green, orange and purple return the chart colours, and the rest keep their old values. Refs dsegroup/code#7999 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
frankbuckley
marked this pull request as ready for review
October 7, 2026 13:27
This was referenced Oct 7, 2026
frankbuckley
added a commit
that referenced
this pull request
Oct 7, 2026
This was referenced Oct 7, 2026
frankbuckley
added a commit
to dseinternational/vocabulary-growth
that referenced
this pull request
Oct 7, 2026
Select dse-research-utils at a1c2656e7d5c303c4938b04168b9b79cf78b2270, the commit v0.18.0 will be cut from, by `rev` until the tag exists. Only dse-research-utils moves in the lock. The library takes its plot colours from the DSE design tokens (dseinternational/research#121). The lock test accepts a `rev` selection and checks that the locked commit is the selected one. 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.
Note
Drafted by a LLM-based AI tool (Claude Code/Opus 5.5).
Summary
The shared plot styles now take their colours from the DSE design tokens, so research figures follow the DSE design language and a group has the same colour in a research figure as on DSE's websites.
plot/design_tokens/colors.jsonis the research colour file generated bydsegroup/apps-common, pinned by its hash indesign-tokens.pin.json. A new test fails if the copy changes. The pin leaves out the usual$schema, which points into an internal repository.CHART_COLOURS(chart-1tochart-6) are the default colour cycle andcategorical_palette()'s default, in place oftab10.sequential_palette(n)anddiverging_palette(n)return three to five ordered steps, each reaching 3:1 against the white background: blue from least to most, or orange (low, negative) to blue (high, positive) with a grey middle step.SEQUENTIAL_CMAPandDIVERGING_CMAPare registered asdse_sequentialanddse_diverging, with_rreversals. The sequential scale replacestab10as the defaultimage.cmap, andviridisasplot_heatmap's default.plot_heatmap(..., centre=0.0)centres the diverging scale, for example for correlations.TEXT_COLOUR,LINE_COLOURand the newMUTED_TEXT_COLOURandBACKGROUND_COLOURtake the design language's text, hairline, secondary text and background colours.Breaking changes
Consumers pin a release tag, so nothing changes for them until they bump.
categorical_palette(n)raisesValueErrorfor more than six series. The design language allows six categorical series: group the smallest, use small multiples or label series directly. A named matplotlibpalettekeeps the old behaviour, for examplecategorical_palette(12, palette="tab20").categorical_palette(n)without apalettereturns hex strings, not RGBA tuples. Code that passes the colours to matplotlib orto_rgb()is unaffected; code that indexes a colour's channels must convert it first.image.cmapandplot_heatmapcolours change, as doTEXT_COLOUR(#333333to#202020) andLINE_COLOUR(#c0c0c0to#d2d8df). Draw a reference line that carries meaning, such as zero, inMUTED_TEXT_COLOUR.COLOUR_*hues are deprecated and raiseDeprecationWarning:COLOUR_BLUE,COLOUR_GREEN,COLOUR_ORANGE,COLOUR_PURPLECHART_COLOURS[0]toCHART_COLOURS[3]CHART_COLOURSentryCOLOUR_RED,COLOUR_YELLOW,COLOUR_DARK_*CHART_COLOURSentry by series order, or an ordered stepKnown consumer changes
Each project changes only when it bumps, but these call sites need attention then:
descriptive.py_shared_group_coloursasks forlen(groups) + extracolours and drops "reddish" ones. Its rule countschart-3orange as reddish, so six or more groups raiseValueError. It needs grouping, small multiples or an explicitpalette.LINE_COLOUR, andtime_to_milestone.pywrites annotation text in it.LINE_COLOURgets lighter, from 1.8:1 to 1.4:1 on white, so those belong inMUTED_TEXT_COLOUR.base_pipeline.pydraws Spearman correlations withplot_heatmap. The default sequential scale puts negative correlations at its quiet end, so those calls should passcentre=0.0.COLOUR_BLUE,COLOUR_ORANGEandCOLOUR_REDin its package modules. Python hides aDeprecationWarningraised outside__main__, so the warnings show only under pytest; blue and orange change colour on bump.Before merging
This pins an unreleased file from
dsegroup/apps-common, where these palettes are now merged and approved. Once a design token release includes them, re-copydist/research/colors.jsonat the release tag and set the pin'stagandsha256. Until then the pin'stagisunreleased.Squash merge with a message that leaves out the first commit's internal issue reference.
Validation
uv run pytest: 1210 passed, 15 skipped. The tests cover the pin, 3:1 contrast for every chart colour and ordered step, the palettes, the deprecated names, the default style and the heatmap's scales.uv run ruff check src/pythonanduv run ruff format --check src/pythonpass.npm run spellcheckandnpm run format:checkpass.uv build --package dse-research-utils: the wheel includesdesign_tokens/colors.json.🤖 Generated with Claude Code