-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
Expose setting hard navigable bounds #6056
Conversation
I was getting some test errors when an element didn't have an extents attribute, so I'm skipping when this is the case. I'm assuming hard bounds are irrelevant for such objects. |
I'm also setting bounds to None for cases where the element.extents are identical (e.g. (10.0, 10.0)) to avoid some test errors like: example test error:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6056 +/- ##
==========================================
- Coverage 88.70% 88.50% -0.20%
==========================================
Files 316 317 +1
Lines 66121 66238 +117
==========================================
- Hits 58650 58627 -23
- Misses 7471 7611 +140
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I disabled hard bounds for one of the UI tests (test_multi_axis_rangexy) in order to have it pass. |
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.
Needs a few unit tests to make sure that:
- The bounds are correctly set for both numeric and datetime axes
- The bounds update when the element updates
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.
One more comment, it's not 100% clear to me if the hard bounds should always be drawn from the combined bounds, i.e. data range, Dimension.range
, Dimension.soft_range
and {x|ylim
or whether that behavior should be configurable.
Several issues remain. We want it to use the largest of data + padding, xlim/ylim, dimension ranges, but it is not yet achieving that. This also does not seem to work for y-axis with |
We determined that dimension ranges are a special, strict case and that a more semantically accurate handling of them includes using them as absolute hard bounds whenever specified, and when So the current plan when
|
We determined that the it's best if the y-axis for |
I think further configurability can be future improvements based on user feedback. This could also include which, if not all, dims the hard bounds should apply to. |
Also need to test overlaid plots, especially when one or both have dim ranges set.. |
Co-authored-by: Philipp Rudiger <prudiger@anaconda.com>
ready for review |
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 have left some small comments, but other than that, this looks good to me.
@@ -1423,7 +1423,7 @@ def _get_range_extents(self, element, ranges, range_type, xdim, ydim, zdim): | |||
|
|||
return (x0, y0, x1, y1) | |||
|
|||
def get_extents(self, element, ranges, range_type='combined', dimension=None, xdim=None, ydim=None, zdim=None, **kwargs): | |||
def get_extents(self, element, ranges, range_type='combined', dimension=None, xdim=None, ydim=None, zdim=None, lims_as_soft_ranges=False, **kwargs): |
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.
Are there other inherited classes that need lims_as_soft_ranges
?
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.
hmm are you hinting at the get_extents
method of the class GenericOverlayPlot
?
It doesn't appear to be necessary because even for overlay plots, GenericElementPlot's version of get_extents
with lims_as_soft_ranges
set to True seems to be called anyway. But honestly it's all pretty confusing and get_extents gets called numerous times so I could be missing something.
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'm not hinting at anything specific; just that other classes could also need to implement lims_as_soft_ranges
if they don't have the super
. But I think we should wait and see if there is a demand for it, before doing anything.
Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
observation, bar charts are only constrained on the continuous axis. I think that's ok for now. see bokeh/bokeh#13830 data = [('one',8),('two', 10), ('three', 16), ('four', 8), ('five', 4), ('six', 1)]
bars = hv.Bars(data, hv.Dimension('Car occupants'), 'Count').opts(apply_hard_bounds=True)
bars Screen.Recording.2024-04-16.at.10.36.37.AM.mov |
Is it possible to disable zooming and panning on the non-continous axis of a bar chart? All it ever seems to do is screw up the plot (as in the gif above); I don't recall ever wanting to do it deliberately and it very often messes up the plot as I'm working with it. |
not declaratively, but you can do something like this if you know which axis is going to be non-continuous:
Screen.Recording.2024-04-17.at.7.57.10.AM.mov |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR closes #1019, which pertains to the lack of hard bounds when panning and zooming using the Bokeh backend.
Why? Previously, the axes were unbounded, allowing users to zoom and pan to potentially empty parts of the data space. This is particularly annoying when a plot captures the scroll of a webpage/notebook/app that it is a part of. This PR
changes the default behavioradds a flag, preventing zooming or panning beyond the data range. update: uses the more extreme of data ranges or xlim/ylim. Update, if dim ranges are set, they are used as hard bounds.To enable this new behavior, use
apply_hard_bounds=True
.Limitation: Currently, setting hard navigable bounds with Bokeh means that if you hit a single extent (e.g. the lower x dim), the zoom won't continue to work for the remaining directions (upper x dim, or any y dim).. Bokeh has an option called
maintain_focus=False
for zoom tools to enable continued zoom. Future work could potentially enable this option in HoloViews whenapply_hard_bounds=True
.Todo:
Demo:
code
Screen.Recording.2024-04-15.at.11.40.17.AM.mov
Only limits the x dim for subcoord_y plots:
code
Screen.Recording.2024-04-15.at.11.29.52.AM.mov