I am graphing time series data with a long history using Plotly, and by default I would like the chart to be zoomed in on the most recent data. I can do this by setting the range argument of the update_xaxes method. However, the Y axis is still set based on the entire history of the data, whereas I would like it calculated on the actually visible data. For instance, in the code below the Y axis will be set to a range of (0,100), even though the visible data only starts at 50 (so expecting a range more like 50-100 on the Y axis). If the user were to then later scroll or zoom the X axis I would want the Y axis to continue to update to accommodate the visible data.
import pandas as pd
import numpy as np
import plotly.express as px
n = 100
df = pd.DataFrame({'x': np.arange(n), 'y': np.arange(n)})
fig = px.line(df, x='x', y='y')
fig.update_xaxes(range=(50,99))
fig.show()
