-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Pixel Ratio #1411
Support Pixel Ratio #1411
Conversation
Thanks! Took a quick skim; could you also add a line to Customization.ipynb to document it's available? |
Sure! Will run the |
I think op_options is missing a comma. Otherwise I think it looks good and I can take a deeper look/merge tomorrow! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied a minor fix to Customization.ipynb; I believe it's ready!
Actually, the test seems to be failing: def test_pixel_ratio(self, da2):
plot = da2.isel(other=0).hvplot(rasterize=True, pixel_ratio=4.0)
opts = Store.lookup_options('bokeh', plot, 'plot')
> assert opts.kwargs['pixel_ratio'] == 4.0
E KeyError: 'pixel_ratio' |
doc/user_guide/Customization.ipynb
Outdated
" Specifies the smallest allowed sampling interval along the x/y axis." | ||
" Specifies the smallest allowed sampling interval along the x/y axis.\n", | ||
" pixel_ratio (default=None):\n", | ||
" Pixel ratio applied to the height and width. Useful for higher\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pointed out by @maximlt, we should also mention this is applicable for datashader operations here and in the docstring.
Bonus if you also mention it for x_sampling/y_sampling!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Let me know what you think of the addition.
Do you have any suggestions on what I could do to fix this and/or how to best test this? |
Thanks for updating customization! Can you also add to docstring? For the failing test, can you see how datashading is asserted? (If there's a test for that)? |
Maybe @maximlt can provide some input, I'm not sure the best way to move forward with the test. |
Let me investigate a bit too. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1411 +/- ##
==========================================
+ Coverage 88.73% 88.91% +0.17%
==========================================
Files 51 51
Lines 7592 7651 +59
==========================================
+ Hits 6737 6803 +66
+ Misses 855 848 -7 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful for higher resolution screens where the PlotSize stream reports 'nominal'
dimensions in pixels that do not match the physical pixels. For
instance, setting pixel_ratio=2 can give better results on Retina
displays.
My understanding is that currently Panel/HoloViews automatically pulls the right ratio based on the user display, so if that's the case this comment is misleading as e.g. users on Retina display will be led to set pixel_ratio=2
while this is already done internally.
Pasting a comment made by @philippjfr elsewhere:
That said I wonder if the pixel_ratio here should be relative to the display pixel ratio or simply override the existing pixel ratio as is done in the PR.
That may be the case, and I'm happy to rephrase it (took this word-for-word from the HoloViews source code) |
@ahuang11 I was reviewing this PR again and read through the original issue (failed to do that previously). I'd like to make sure we're going in the right direction as exposing Jim suggested 3 options, Philipp being happy with options 1 and 3.
I like option 1 too and somewhat disagree with the cons cited by Jim, it seems to be hvPlot could document the main keys that can be set via this dict argument. Pretty sure there are ways to type this dictionary so that users would get help from their IDE to populate it (well not yet in Jupyter). Option 3 is what I think is implemented with I would also like us to address this question before merging:
|
I can create a separate issue on this topic if you'd like, As for the design, I'm open to any considerations. |
Depends how useful pixel_ratio is; if it's really useful I vote for 3; if not 1. Option 1 is similar to colorbar_opts; I shy away from having to call colorbar_opts because I never remember the proper kwarg values.
Sounds like a dataclass / pydantic model / parameterized |
I've found pixel ratio to be extremely useful when paired with Zoomed (Default Pixel Ratio)Zoomed (
|
I'm in favor of having pixel_ratio exposed directly. |
@philipc2 I took the liberty to push a commit with some changes to the docstring and re-ordering. In the end, I decided that adding
But in general @ahuang11 I think we need to be careful when adding new parameters to hvPlot, because of the flat namespace this adds a cost to all users of hvPlot. |
Thanks @philipc2 ! |
Closes #626
Overview
pixel_ratio
parameterExample Plots