Fix datashader elements invisible with non-square aspect ratios#544
Merged
Fix datashader elements invisible with non-square aspect ratios#544
Conversation
…ents The canvas sizing used np.min to pick the scaling factor, which preserved square pixels but could make the canvas many times larger than the display on one axis. Pixel-based operations (spread, line_width) were then downscaled to sub-pixel size, making points and outlines invisible. Using np.max ensures the canvas never exceeds display pixels on either axis. This fixes visibility with non-square aspect ratios (e.g. scale transforms) while maintaining visual quality for all element types. Fixes #445 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #544 +/- ##
=======================================
Coverage 84.00% 84.00%
=======================================
Files 9 9
Lines 2601 2601
=======================================
Hits 2185 2185
Misses 416 416
🚀 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
Scale([1, 5]))_get_extent_and_range_for_datashader_canvasusednp.minto compute the scaling factor, which made the canvas up to ~9× larger than the display on the longer axis. All pixel-based operations (spread,line_width) were then downscaled to sub-pixel size during displaynp.min→np.max, ensuring the canvas never exceeds the display resolution on either axisDetails
With
np.min, the canvas matched display pixels on the shorter axis but was oversized on the longer one:With
np.max, the canvas is capped to display resolution:Verified no visual quality degradation for shapes, outlines, labels, images, or dense point clouds — the extra canvas pixels produced by
np.minwere always downscaled away during display and contributed nothing visible.Test plan
test_datashader_points_visible_with_nonuniform_scaleregression testmain)🤖 Generated with Claude Code