Skip to content

Custom Colour Scale Creation - #262

Merged
Felix-Mallinder merged 8 commits into
developfrom
Python_Toolkit-#214-CustomCmapGenerator-clean
Nov 19, 2026
Merged

Felix-Mallinder merged 8 commits into
developfrom
Python_Toolkit-#214-CustomCmapGenerator-clean

Conversation

@Felix-Mallinder

@Felix-Mallinder Felix-Mallinder commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Issues addressed by this PR

Closes #217

Adds custom colour maps and colour scales to the BHoM Tkinter UI.

A colour scale keeps its band thresholds in data units (e.g. 18 / 21 / 24 degC) and gives a matching matplotlib (Colormap, BoundaryNorm), so a saved scale colours any data consistently.

  • palettes: one registry of matplotlib and toolkit palettes, with a colourblind set.
  • colour_scales: ColourScale, break suggestion from data (equal, quantile, jenks, nice, log) and a saved scales file (load_scales, save_scale, delete_scale).
  • plot/colour_scale_histogram.py: histogram of data over a scale's bands, used as the builder preview.
  • ColourScaleBuilder window: histogram, suggested breaks, edit thresholds, colours and labels, split or remove bands, save.
  • CmapSelector: new include_scales, data, units and scales_path options. Saved scales are listed as Name (scale) with New / Edit / Delete buttons, and get_scale() / get_norm() return the selection.
  • CmapSelector palette lists now come from palettes, so CATEGORICAL_CMAPS and CONTINUOUS_CMAPS are removed. Nothing in this repo used them.

Test files

Tests included: tests/test_colour_scales.py and tests/test_colour_scale_builder.py.

Changelog

  • Added palettes and colour_scales modules.
  • Added ColourScaleBuilder.
  • CmapSelector can build, edit and delete saved colour scales.

Additional comments

palettes and colour_scales moved out of plot/ into their own modules, per review.

@Felix-Mallinder Felix-Mallinder self-assigned this Oct 28, 2026
@Felix-Mallinder Felix-Mallinder added the status:WIP PR in progress and still in draft, not ready for formal review label Oct 28, 2026
@Felix-Mallinder Felix-Mallinder added type:feature New capability or enhancement and removed status:WIP PR in progress and still in draft, not ready for formal review labels Nov 10, 2026
@Felix-Mallinder
Felix-Mallinder marked this pull request as ready for review November 10, 2026 12:50

@Tom-Kingstone Tom-Kingstone left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to reject this immediately as methods in the plot submodule should actually plot things, move them into a new/different submodule.
The only exception is plot helpers (which I can see that some of these might fit into)

If you want them as described in the changelog you would have the following structure:

  • Python_Engine/Python/src/python_toolkit
    • plot
      • ...
    • palettes
      • ...
    • colour_scales
      • ...

@Tom-Kingstone Tom-Kingstone left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good now, and that display function for the drop down is also probably going to be useful elsewhere (every day we get closer to fully supporting enums in drop downs ;)).

Noting here an idea for the registry is to have some sort of "colour scale category" that can be sorted by (i.e. how matplotlib categorises them in their colour map page) of course a scale can have multiple categories (colour blind safe + categorical, colour blind safe + continuous etc.)

@Tom-Kingstone

Copy link
Copy Markdown
Contributor

@BHoMBot check required

@Felix-Mallinder

Copy link
Copy Markdown
Contributor Author

@BHoMBot check ready-to-merge

@bhombot-ci

bhombot-ci Bot commented Nov 19, 2026

Copy link
Copy Markdown

@Felix-Mallinder to confirm, the following actions are now queued:

  • check ready-to-merge

There are 187 requests in the queue ahead of you.

@Felix-Mallinder
Felix-Mallinder merged commit aae3584 into develop Nov 19, 2026
19 checks passed
@Felix-Mallinder
Felix-Mallinder deleted the Python_Toolkit-#214-CustomCmapGenerator-clean branch November 19, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New capability or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Colormap builder

2 participants