-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Axis auto-range improvements #1876
Comments
One other idea we've discussed is autoranging one axis based on only the data that's visible on the opposite axis or axes - for example zoom in on a particular x range and autorange y based only on the x data in that range. Perhaps |
Thanks to @cldougl for pointing me in this direction. I just want to throw my 2 cents in and say that, as per plotly/plotly.py#826, it would be nice if plots where all traces set fill |
@petergaultney thanks for the note - we definitely intend to make all of this more configurable. But another (fairly new) option that might be useful to you is plotly/plotly.py#1861 - |
sure enough, with those two options combined my problem is actually solvable. I set |
There's also #1022 about adding |
From plotly/plotly.py#2083 - certain trace types (bars, fill to zero) currently force the axis autorange to include zero. We should let the user override that. |
Does anyone have a clear picture how to combine all ideas? Since #2158 closed in favor of this issue, I am ready to contribute but I think I need some guidance. |
For resolving plotly/plotly.py#2158, I think all you need (API-wise) is adding That is, |
@etpinard sorry, I am a little bit confused. Demo: https://codepen.io/plotly-demo/pen/JOERgj Nevertheless, |
JFYI: Since this issue is about addressing all auto-range related issues and requires significant amount of time to do in a right way, for now, I will implement a wrapper around PlotlyJS in order to solve my case and continue to watch on progress. |
Per @ IanWorthington in plotly/plotly.py#2439 - we should make sure |
I think this use case will be covered by the options discussed above, however, I would like to share it anyway since it hasn't been said explicitly. Often I am working with data sets that whose X or Y coordinates are, for example, only positive, as demonstrated here: jsbin/winaki/6. I would really like to be able to prevent the pan and zoom controls from adjusting the axes to go beyond set limits (instead they should "snap"/"stick"/"rubber band" when they reach them). |
Any news on this subject? Especially the "bug" that the y-axis range is not updating when x-axis rangeslider is used (see: plotly/plotly.js#6958, plotly/plotly.py#2439 , #912) and the white spaces when using the "lines+text" mode plotly/plotly.py#1775 . |
Any news for this? |
can we start sponsoring this feature? how much? |
did people give up on this? wow |
The sponsorship amount is listed above, and so far no one has stepped up to sponsor, and it's not on the core team's roadmap at this point, although we'd be happy to accept some pull requests :) |
+1 |
ive been able to implement this by catching "xaxis.range" in the arguments keys during .on("plotly_relayout", function(event, arguments {}) then getting the indexes of the new start and end values for x axis, after that i get the min and max from my y value arrays between those indexes and then create an update var update = { ps: with some comments and console logs sprinkled in this implementation took me 40 lines of code so its not terribly hard to implement yourself using existing charts |
- This can be useful for highlighting data points that are separate to the main series - Note that Plotly automatically adds padding to the left and right of the series when marker dots are selected. This behaviour is discussed here: plotly/plotly.js#1876
+1 |
Discovered this issue when looking for if plotly.js (the javascript version specifically) supported "soft ranges" similar to how grafana does it, with the Y-axes min/max being expanded to encompass all visible data. This would be great for us to avoid making mountains out of mole-hills, but still display all data in view if data unexpectedly extends beyond the min/max range set. |
Is this feature still not possible in R? I understand it is in Phyton right with fig.update_yaxes(fixedrange=False)? |
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as abuse.
This comment was marked as abuse.
Hi, I went through many forums, but couldn't find any recent update on that feature i.e. auto-scaling of y-axis according to the "visible" x values (a subset of all x values selected via range-slider). I really need that feature :-) but setting From my understanding the need has been expressed since 2017, but there wasn't any progress because this feature is complex and would require a substantive sponsorship (between 15,000$ and 20,000 $). Am I missing something ? I would be so happy to hear that this feature exists ! |
The issue is anything but complex. I used a callback on any change of the visible x-axis range and then within the callback derived the y-min and y-max within the currently visible x-axis range and subsequently update the y-axis range. Done. I uploaded an example screen capture of a solution implemented in Bokeh (I was not sure how plotly callbacks are implemented). It really is very straightforward, I have no idea why so many here find this a complex issue. Recording.2023-05-09.091324.mp4 |
you just have to do this for the x axis change event (not sure why this was downvoted lol) #1876 (comment) |
Very similar to how I have done this. Not sure why this would require a significant amount of sponsorship to implement a few lines of code and to write a few tests. My implementation in the JS callback took me 16 lines of code (though its a Bokeh implementation). From multiple posts on this issue by core contributors it appears that the feature is not really understood to begin with. |
I'm happy to see the extra discussion around this topic - FYI we have a PR currently in progress to cover a lot of these use cases: #6547 - we have a bit more work to do on it, but comments are welcome. |
By utilizing relayoutData and figure, you can effortlessly achieve these features through a single, straightforward callback(max 20 lines of code). |
#6547 (released in v2.26.0) covered a lot of the use cases here, but there's a lot that's been discussed here, I see at least three more pieces still open:
Any I missed? @archmoj I wonder if we should make new issues for the two pieces that don't already have their own issues, and close this one? It's gotten too big and diffuse to be very useful anymore, and most of it is done. |
Bumping this for visibility. What would be the sponsorship cost for a soft autorange mode? My interpretation of soft autorange mode:
Hard max and hard min can hide important data in many cases, so I'm very hesitant to implement something like that. |
This issue attempts to combine ideas from several individual feature requests into coherent picture (i.e. the least number of new attribute possible).
In a private conversation with @alexcjohnson , we proposed adding two new (cartesian) axis attributes:
bounds
andboundmode
.bounds
would expect 2-item array values similar to the currentrange
.bounds
can be thought of as representing the maximum possible extend of the axis ranges. In turn,boundmode
would determine ifbounds
applies during the auto-range routine (i.e. on first view - discuss in #1861 (comment)) or during interactions as well (as proposed in #887). For example,would restrict the auto-range logic to compute an x-axis
range
between 0 and 100. This might be useful when plotting percentages where users don't want the axis ranges to go beyond 100%.would restrict the axis range to
[0,100]
in the auto-range logic and during interactions.In doing so, 1-way
bounds
values such as[null, 100]
or[0, null]
should be allowed.null
items here mean don't restrict the min (or max) bound acting. This behavior is similar tocmin
andcmax
for color scales. This call signature should also be extended to the axisrange
attribute - taking care of #400A few more things to think about:
'tight'
value for axisautorange
would take care of Implement different data-based autorange mode #928'once'
value for axisautorange
for .animate method that can handle any type of figure diff #1849range
(andbounds
) values for Range selectors + streaming and/or markers #387The text was updated successfully, but these errors were encountered: