Skip to content
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

Feature request: Axis boundaries #887

Closed
g-i-o- opened this issue Aug 26, 2016 · 23 comments
Closed

Feature request: Axis boundaries #887

g-i-o- opened this issue Aug 26, 2016 · 23 comments
Labels
feature something new

Comments

@g-i-o-
Copy link

g-i-o- commented Aug 26, 2016

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 fixedrange attribute, 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: bounds and boundsmode. bounds gets checked in the panning and zooming logic and, if set, it constrains the range to the specified bounds. boundsmode allows the bounds to be computed automatically from the plot (like autorange). 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.


  1. Here we have a nice little heatmap:
    newplot
  2. But then some user starts using with the panning tool a bit too much:
    newplot 1
@etpinard
Copy link
Contributor

etpinard commented Sep 1, 2016

Yes, that would be a great addition to the library.

We already partly have this concept for ternary plots using the axis min attribute.

So, maybe for consistency, we should add axis.min and axis.max to cartesian axes with default values being null corresponding to no limits. Thoughts?

@etpinard etpinard added the feature something new label Sep 1, 2016
@g-i-o-
Copy link
Author

g-i-o- commented Sep 3, 2016

axis.min and axis.max sounds ok. Any thoughts on how should axis.boundsmode should be called? the idea is that axis.boundsmode can be set to 'auto' and then the max and min are set using the autorange funcionality.

@etpinard
Copy link
Contributor

etpinard commented Sep 6, 2016

Why would we need axis.boundsmode ?

@g-i-o-
Copy link
Author

g-i-o- commented Sep 6, 2016

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 bounds

@etpinard
Copy link
Contributor

etpinard commented Sep 7, 2016

Oh I see. I guees a axis.boundsmode would be nice to toggling between set bounds and auto computed 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 false instead of axis.boundsmode.

@talgalili
Copy link

BUMP, any chance this feature could be added?

Thanks!

@jasjes
Copy link

jasjes commented Sep 24, 2018

PING! Would LOVE the ability to limit zoom-out and pan so the user can't move beyond available data.

@ajschmidt8
Copy link

+1

@chrisdaniells
Copy link

This would be great, not being able to prevent infinite zoom/pan is a pain!

@jvandort
Copy link
Contributor

Seriously, how is this not a feature? I'd expect something basic like limiting axis bounds to be implemented.

@MrQubo
Copy link

MrQubo commented Nov 4, 2019

I've made some work towards implementing this feature here: MrQubo#3
Any help will be appreciated.

@Nabeelhassan
Copy link

When can we expect this feature?

@DaveShuckerow
Copy link

Bump: This would be an extremely useful feature to have.

@nicolaskruchten
Copy link
Contributor

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.

@MrQubo
Copy link

MrQubo commented Jul 14, 2020

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.

@jackparmer
Copy link
Contributor

jackparmer commented Sep 10, 2020

This issue has been tagged with NEEDS SPON$OR

A 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.

@samuelnimi
Copy link

That type of feature would be really awesome!

@AviadAvr
Copy link

AviadAvr commented Nov 7, 2023

BUMP

This feature would be super useful!

@alexcjohnson
Copy link
Collaborator

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!

@nicolaskruchten
Copy link
Contributor

Out 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?

@alexcjohnson
Copy link
Collaborator

Oh that's an interesting idea, but no I don't believe it's possible currently.

@archmoj
Copy link
Contributor

archmoj commented Nov 8, 2023

@nicolaskruchten Good idea. Simply tracked in #6779. Thank you!

@bozobec
Copy link

bozobec commented Jan 10, 2024

Is this new feature limited to Plotly express? Is it going to be merged to Plotly eventually?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

No branches or pull requests