Axis auto-range improvements
See original GitHub issueThis 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
and boundmode
. bounds
would expect 2-item array values similar to the current range
. bounds
can be thought of as representing the maximum possible extend of the axis ranges. In turn, boundmode
would determine if bounds
applies during the auto-range routine (i.e. on first view - discuss in https://github.com/plotly/plotly.js/pull/1861#issuecomment-314518657) or during interactions as well (as proposed in https://github.com/plotly/plotly.js/issues/887). For example,
xaxis: {
autorange: true,
boundmode: 'soft',
bounds: [0, 100]
}
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%.
xaxis: {
boundmode: 'hard',
bounds: [0, 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 to cmin
and cmax
for color scales. This call signature should also be extended to the axis range
attribute - taking care of https://github.com/plotly/plotly.js/issues/400
A few more things to think about:
- Adding a
'tight'
value for axisautorange
would take care of https://github.com/plotly/plotly.js/issues/928 - Maybe adding
'once'
value for axisautorange
for https://github.com/plotly/plotly.js/issues/1849 - Maybe allow span axis
range
(andbounds
) values for https://github.com/plotly/plotly.js/issues/387
Issue Analytics
- State:
- Created 6 years ago
- Reactions:43
- Comments:46 (18 by maintainers)
Top GitHub Comments
Any news for this? The yaxis.autorange: ‘visible’ is really needed across the forums and is making lot of people moving to other libs.
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
autorange: 'visible'
?