Feature request: Axis boundaries #887
Description
Activity
Yes, that would be a great addition to the library.
We already partly have this concept for ternary plots using the axis
minattribute.So, maybe for consistency, we should add
axis.minandaxis.maxto cartesian axes with default values beingnullcorresponding to no limits. Thoughts?Reacted by coriusraxis.minandaxis.maxsounds ok. Any thoughts on how shouldaxis.boundsmodeshould be called? the idea is thataxis.boundsmodecan be set to'auto'and then themaxandminare set using the autorange funcionality.Why would we need
axis.boundsmode?Currently, with
axis.boundsmode='auto'the bounds are set automatically using the plot's autorange feature. That way you can just show the data and the plot doesn't allow the user to pan/zoom outside the plot boundsOh I see. I guees a
axis.boundsmodewould be nice to toggling between set bounds andautocomputed bounds.Can you think of other bounds mode besides
'auto'and set-by-axis.min/axis.max?In the case where there are only two possible modes, I'd vote for calling adding a boolean attribute e.g.
axis.autobounds = true // or falseinstead ofaxis.boundsmode.BUMP, any chance this feature could be added?
Thanks!
PING! Would LOVE the ability to limit zoom-out and pan so the user can't move beyond available data.
Reacted by mewald55, AJ Schmidt, James Dalgleish, Q6 Yav, Abel Serrano Juste, Simon, jansiebert1, Chris Daniells, AlexanderZinchenko, João Vítor Nunes and 5 more+1
This would be great, not being able to prevent infinite zoom/pan is a pain!
Seriously, how is this not a feature? I'd expect something basic like limiting axis bounds to be implemented.
I've made some work towards implementing this feature here: MrQubo#3
Any help will be appreciated.Reacted by coriusrWhen can we expect this feature?
Bump: This would be an extremely useful feature to have.
We'd be happy to work with someone from the community to implement this feature, but it's not on our roadmap at this time.
My code from Nov 4, 2019 was working for my use-case (column and sparse plots). MrQubo#3
It requires testing and probably some adjustments to work with other plot types. Updating it to the current version of plotly.js might require some additional work as well.
I'm not planning to work on this anymore but it's there if someone from community was to pick it.This issue has been tagged with
NEEDS SPON$ORA community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort.
What Sponsorship includes:
- Completion of this feature to the Sponsor's satisfaction, in a manner coherent with the rest of the Plotly.js library and API
- Tests for this feature
- Long-term support (continued support of this feature in the latest version of Plotly.js)
- Documentation at plotly.com/javascript
- Possibility of integrating this feature with Plotly Graphing Libraries (Python, R, F#, Julia, MATLAB, etc)
- Possibility of integrating this feature with Dash
- Feature announcement on community.plotly.com with shout out to Sponsor (or can remain anonymous)
- Gratification of advancing the world's most downloaded, interactive scientific graphing libraries (>50M downloads across supported languages)
Please include the link to this issue when contacting us to discuss.
That type of feature would be really awesome!
BUMP
This feature would be super useful!
Ah, this feature was actually released just recently as
axis.minallowed/axis.maxallowed- added in plotly.js v2.26 / plotly.py v5.17, via #6547
See https://plotly.com/python/axes/#setting-a-maximum-and-minimum-allowed-axis-value for usage from Python!Reacted by Nicolas Kruchten and John Paul DepewReacted by Ariel Matías CabelloOut of curiosity: is there an easy way of tying minallowed/maxallowed to the computed range? Basically to let Plotly.js compute the autorange and set min/max allowed to that automatically, thereby implementing "zoom in but not out" without having to separately compute ranges outside of Plotly.js?
Reacted by Mojtaba SamimiOh that's an interesting idea, but no I don't believe it's possible currently.
Reacted by Mojtaba Samimi@nicolaskruchten Good idea. Simply tracked in #6779. Thank you!
Reacted by Nicolas KruchtenIs this new feature limited to Plotly express? Is it going to be merged to Plotly eventually?
@alexcjohnson I don't think this is working correctly. You can still pan as much as you want until you get empty plots. Plotly just zooms into the plot while keeping the
maxallowedlimit until you do not have datapoints in your infinitesimal range anymore. Then there also is axis label flickering while panning over themaxallowedlimit up to the point that the axis shows all labels again, although you are far over themaxallowedlimit already.Why can't you just stop the panning during the drag when the axis reaches
maxallowed? And why can't I disallow the completely unintuitive zooming while panning. Users are using pan exactly because they do not want the absolute value of the range between current visible max and current visible min to change (e.g. to always look at a span of 10 years while panning). This only works until you reach themaxallowedlimit.
Hi, I just recently started using your plotting library (which is awesome by the way) to do some heatmap plots. One of the main complaints I've received have been the ability to pan outside the plot's boundaries (just click and drag the plot outside the viewport and suddenly the axis range point to some non-data containing area). While this can be mitigated with the
fixedrangeattribute, you end up losing the pan and zoom features for that axis.So, I was thinking that maybe adding axis boundaries could be a thing? Maybe two more properties could be added to the axes:
boundsandboundsmode.boundsgets checked in the panning and zooming logic and, if set, it constrains the range to the specified bounds.boundsmodeallows the bounds to be computed automatically from the plot (likeautorange). That way users can zoom and pan al around the plot, but cannot get outside the plot bounds.As proof of concept I have created this pull request g-i-o-/plotly.js#1 on my fork and was thinking maybe you guys could check it out comment on how to improve and, if you like it, add it or something like that.