Fix user figure DPI silently overridden by pl.show()#575
Merged
Conversation
When a user created a figure with a custom DPI (e.g. plt.figure(dpi=300)) and passed its axes to .pl.show(ax=ax), the DPI was silently overwritten with the rcParams default. This happened because _prepare_params_plot() unconditionally resolved dpi=None to rcParams["figure.dpi"] and then called fig.set_dpi() on the user's figure. Now the figure's existing DPI is preserved when the user provides their own axes without an explicit dpi= argument. Explicit dpi= still overrides. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
A regression that overrides the user's DPI to the default (~100) would produce a noticeably sharper render that fails baseline comparison. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ization The rasterization code skips images under 2000x2000 regardless of DPI, so varying DPI has no visible effect on the blobs test data. The unit tests already verify the DPI value is correctly preserved. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The guard `if x_dims < 2000 and y_dims < 2000: do_rasterization = False` silently ignored the user's DPI intent — a low-DPI figure should still trigger downsampling when the source image exceeds the target resolution. Also re-adds the visual test for #310: at dpi=15 the 512x512 blobs image is now correctly downsampled to ~96x72, producing visibly pixelated output that would fail baseline comparison if DPI were overridden to the default. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The pixelated render confirms rasterization now respects the user's dpi=15 setting — the 512x512 image is downsampled to ~96x72. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
10 tests failed because labels/images now correctly rasterize when the source (512px) exceeds the target resolution (DPI=80 × canvas). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
bbec8e6 to
66b8446
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #575 +/- ##
==========================================
- Coverage 75.42% 75.36% -0.06%
==========================================
Files 10 10
Lines 2934 2935 +1
Branches 683 684 +1
==========================================
- Hits 2213 2212 -1
- Misses 440 441 +1
- Partials 281 282 +1
🚀 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.
Fixes #310.
_prepare_params_plot(): preserve user figure DPI whenax=is passed without explicitdpi=_rasterize_if_necessary(): remove blanket< 2000pxguard that skipped rasterization regardless of DPI