Draft
Conversation
Add a `channels_as_categories: bool = False` parameter to `render_images()` that shows a categorical legend mapping each channel name to its compositing color for multi-channel images. Legend entries are accumulated across chained `render_images()` calls and drawn as a single combined legend after the render loop, following the same deferred pattern as colorbars. When labels or shapes also contribute legends on the same axes, the channel entries merge automatically via matplotlib's artist-based legend collection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace local macOS baselines with CI-generated (Linux) images for the 5 existing channel legend tests. Add 2 new visual tests for legend positioning (upper left, lower right) to verify legend_loc is respected by the channel legend. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace all 7 channel legend baselines with images generated on the GitHub Actions runner (Linux) to match the CI rendering environment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #576 +/- ##
==========================================
+ Coverage 75.36% 75.43% +0.07%
==========================================
Files 10 10
Lines 2935 2976 +41
Branches 684 691 +7
==========================================
+ Hits 2212 2245 +33
- Misses 441 446 +5
- Partials 282 285 +3
🚀 New features to boost your workflow:
|
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.
Summary
channels_as_categories: bool = Falsetorender_images()— whenTrue, shows a categorical legend mapping each channel name to its compositing colorrender_images()calls and merge with labels/shapes legends on the same axesCloses #459
Details
The feature follows the same deferred-draw pattern as colorbars:
_render_imagescollectsChannelLegendEntryobjects into a per-axis list, and_draw_channel_legenddraws a single combined legend after the render loop completes. This avoids the matplotlib single-legend-per-axes limitation when chaining multiplerender_imagescalls.Edge cases handled:
legend_loc="on data": falls back to"right margin"with a warning (no scatter coordinates for placement)multi_panel): avoids double-shrinking axes when a labels/shapes legend already applied the shrink