I am trying to make a candle stick chart using plotly. I am using stock data spanning over 10 years. Due to this the candles appear very small as the y axis has a large scale. However if I zoom into a smaller time period (lets say any 1 month in the 10 years) I want the y axis scale to change so that the candle looks big. Below is my code:
df_stockData = pdr.DataReader('TSLA', data_source='yahoo', start='2011-11-04', end='2021-11-04')
fig = make_subplots(rows=2, cols=1, shared_xaxes=True, row_width=[0.25, 0.75])
fig.add_trace(go.Candlestick(
x=df_stockData.index,
open=df_stockData['Open'],
high=df_stockData['High'],
low=df_stockData['Low'],
close=df_stockData['Close'],
increasing_line_color='green',
decreasing_line_color='red',
showlegend=False
), row=1, col=1)
fig.add_trace(go.Scatter(
x=df_stockData.index,
y=df_stockData['RSI_14'],
line=dict(color='#ff9900', width=2),
showlegend=False,
), row=2, col=1
)
fig.show()
As you can see the y-axis (stock price) has a very large scale. Even if I zoom in to a smaller time period the y axis scale remains the same. Is there any way to make the y-axis scale change dynamically so that the candles appear bigger when I zoom in?


