Double Click/Reset Axis/Autoscale does not respect custom range set for axes
The problem was reported here and here and it hasn't been fixed since 2018!
When you set a custom x-axis range, double clicking/reset axis/autoscale actions reset the custom range. The expected behaviour is to respect the custom ranges.
The current workaround is a function that creates a Div (with Graph/Figure) directly in the layout that can then be updated later via callbacks.
I also found another easier solution. Instead of setting the range for the xaxis, we could just use:
autorangeoptions = dict(clipmin = min_value, clipmax = max_value)
and then remove the range set for the axis.
This fix unfortunately only works if the desired min/max are inside the values chosen by autorange. For example, if the desired range is [0, 10] and autorange sets the axis limits to [2, 8] by default then there is no way to force autorange to produce [0, 10]. On the other hand, if the desired range is [5, 6], then the above solution works great.
For the special case where the desired range starts at zero, you can get around this by using a combination of autorangeoptions and rangemode="tozero". For example:
fig.update_yaxes(
rangemode="tozero", # enforces zero lower bound
autorangeoptions=dict(maxallowed=10, include=10), # enforced 10 upper bound
)
thanks for the report @arman258 - I'm sorry we haven't been able to find someone to work on this since it was first reported. It's in our backlog; if someone submits a community PR, I'd be happy to prioritize review.