Fix double artist registration in render_labels and render_points#634
Merged
Fix double artist registration in render_labels and render_points#634
Conversation
ax.imshow and ax.scatter already register the returned artist in ax.images / ax.collections internally. The subsequent ax.add_image / ax.add_collection calls inserted a second reference to the same object, causing the layer to be composited twice and making effective alpha 1-(1-alpha)^2 instead of alpha. Fix: drop the redundant add_image / add_collection calls and return the artist directly. Closes #594
…date reference images The _cax intermediate was introduced alongside the now-removed ax.add_image / ax.add_collection calls. With those calls gone, the variable serves no purpose -- rename directly to cax at the scatter / imshow call site. Reference images for visual tests regenerated from CI artifacts to reflect the corrected single-compositing alpha output. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #634 +/- ##
==========================================
- Coverage 76.33% 76.32% -0.02%
==========================================
Files 11 11
Lines 3229 3227 -2
Branches 757 757
==========================================
- Hits 2465 2463 -2
Misses 465 465
Partials 299 299
🚀 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
ax.imshow()andax.scatter()already register the returned artist inax.images/ax.collectionsinternally. The subsequentax.add_image()/ax.add_collection()calls inserted a second reference to the same object, so matplotlib composited the layer twice.fill_alpha=0.4this produced effective opacity1-(1-0.4)^2 = 0.64instead of0.4. The default labels alpha of0.4was effectively0.64on every plot.Closes #594