Autorange property of update_yaxes does not work upon zooming in
in func blw the row before the last (fig.update_yaxes(autorange=True)) does not produce any result: the Y axis remains unchanged upon zooming in the chart.
def chart_symbol(symbol, df): fig = make_subplots(rows=3, cols=1, subplot_titles=[symbol, 'Volume', 'ATR(14)'], shared_xaxes=True) fig.add_trace(go.Candlestick(x=df.date, open=df.open, high=df.high, low=df.low, close=df.close, name=symbol, showlegend=False), row=1, col=1) fig.add_trace(go.Scatter(x=df.date, y=df.dma10, line=dict(color='blue', width=2), name='10dma'), row=1, col=1) fig.add_trace(go.Scatter(x=df.date, y=df.dma20, line=dict(color='violet', width=2), name='20dma'), row=1, col=1) fig.add_trace(go.Scatter(x=df.date, y=df.dma50, line=dict(color='orange', width=2), name='50dma'), row=1, col=1) fig.add_trace(go.Bar(x=df.date, y=df.volume, name='Volume'), row=2, col=1) fig.add_trace(go.Scatter(x=df.date, y=df.vol30dma, line=dict(color='darkblue', width=1), name='Vol30dma'), row=2, col=1) fig.add_trace(go.Scatter(x=df.date, y=df.ATR, line=dict(color='darkblue', width=1), name='ATR(14)'), row=3, col=1) fig.update(layout_xaxis_rangeslider_visible=False) fig.update_yaxes(autorange=True) fig.show()
yaxis_autorange=True is the default setting. Hence fig.update_yaxes(autorange=True) has no effect.
See this reference: https://plotly.com/python/reference/layout/yaxis/#layout-yaxis-autorange
Only fig.update_yaxes(autorange=False), respectively fig.update_yaxes(autorange="reversed") has a visible effect:
import numpy as np
import plotly.graph_objects as go
fig=go.Figure()
fig.add_scatter(x=np.arange(6), y=[1.2, 4.25, 3.02, 1.7, 2.3])
fig.add_scatter(x=np.arange(6), y=[-0.75, 4.67, 3.14, 2.8, 7.35])
fig.show()
fig.update_yaxes(autorange=False) # or "reversed"
I have a similar problem now.
If you have subplots with shared_xaxes=True, that is natural to do in time series using the X axis, the autorange only works in the chart you are doing the box select.
All the other charts apply the box selection but don't apply the yaxis autorange for the new data window.
I'm trying to solve it using Dash callbacks, but can't find a way to clearly check which data is in each chart, so it's not easy to do because there is a lot of circular information in the internal data structure.
I would expect to autorange to work in all the yaxis while selecting a box in one of the subplots while sharing xaxes, but it's not working.
Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson