Viz 01: Unify cluster palette and add discrete palette#1716
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1716 +/- ##
===========================================
- Coverage 84.35% 84.33% -0.03%
===========================================
Files 164 165 +1
Lines 14752 14796 +44
===========================================
+ Hits 12444 12478 +34
- Misses 2308 2318 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a unified, user-overridable visualization style mechanism for cluster-related coloring across multiple pypesto.visualize plotters, switching defaults to a categorical palette and reserving distinct colors for the MLE and singleton/outlier starts.
Changes:
- Added
pypesto.visualize._stylewith default style constants and aresolve_style(style_kwargs)helper. - Threaded a resolved
styledict through color assignment utilities and result-list processing to ensure consistent palette selection. - Added
style_kwargsto user-facing plotters andstyleto low-level plotting functions to avoid repeated style resolution.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pypesto/visualize/_style.py | New style registry/constants and resolve_style merge+warning helper. |
| pypesto/visualize/clust_color.py | Uses a discrete/categorical palette with filtering to keep MLE/outlier colors distinct; propagates style. |
| pypesto/visualize/misc.py | Threads style into process_result_list so per-result palettes use the resolved style. |
| pypesto/visualize/waterfall.py | Adds style_kwargs and forwards resolved style into coloring/lowlevel routines. |
| pypesto/visualize/parameters.py | Adds style_kwargs and forwards resolved style into coloring/lowlevel routines. |
| pypesto/visualize/optimizer_history.py | Adds style_kwargs and forwards resolved style into coloring/lowlevel routines. |
| pypesto/visualize/optimization_stats.py | Adds style_kwargs and forwards resolved style into coloring/palette selection and lowlevel routines. |
| pypesto/visualize/profiles.py | Adds style_kwargs and forwards resolved style through result/profile-list processing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The cluster-coloured plotters (
waterfall,parameters,optimization_stats,optimizer_history,profiles) all had their cluster palette hardcoded with no user override path. That default sometimes produced indistinguishable cluster colours. As @PaulJonasJost suggested, a default categorical palette works better. One can change it using astyle_kwargsoverride path. I also added a guarantee the palette stays far from the MLE (default red) and isolated point (default grey) colors.Main changes:
pypesto/visualize/_style.pywith the reserved colours (MLE_COLOR = tab:redfor the best cluster,OUTLIER_COLORfor singletons) and the cycled palette source (CMAP_DISCRETE, default"tab10"), plus a smallresolve_stylehelper_build_cluster_palettesamples non-best cluster colours fromcmap_discretewith a small distance filter — that way the reserved best/outlier colours stay visually distinct from the cycled ones even when someone passes a cmap that happens to contain red or greystyle: dict | Nonethreaded throughassign_clustered_colors,assign_colors,assign_colors_for_list,process_result_liststyle_kwargs: dict | None = Nonekwarg; their lowlevel counterparts (waterfall_lowlevel,parameters_lowlevel,optimizer_history_lowlevel,stats_lowlevel) take an already-resolvedstyle: dict | None = None. Soresolve_styleruns exactly once per call chain at the user-facing boundary.This is the first in a small series of visualisation PRs. The rest of
_style.py(constants for bounds, scatter, colorbars, …) grows incrementally as later PRs polish each visualisation family.