Y-axis autoscaling with x-range sliders

Hi thank you for your solution it exactly what i need it…
However i was unable to implement correctly the code
could someone figure it out what wrong in the last part for this code
Thank

fig = go.FigureWidget(data=data, layout=go.layout)
fig

#Y-axis autoscaling with x-range sliders

def zoom(layout, xrange):
in_view = df.loc[fig.layout.xaxis.range[0]:fig.layout.xaxis.range[1]]
fig.layout.yaxis.range = [in_view.trace_low.min() - 2, in_view.trace_high.max() + 2]

fig.layout.on_change(zoom, ‘xaxis.range’)

fig

plotly.offline.plot(fig, filename = “Time Series Forecast Multivariable (61) MultiStep (3).html”)