After a long search, I could not find any thread/discussion helping me to make autoscaling work with plotly.
The idea would be that when I use the x-range slider to go through the data, the y-axis would be dynamically rescaled each time I move the slider.
Currently, this is how it looks like (pretty unuseful):
fig = plt.figure()
# Layout format and buttons
layout = dict(
xaxis=dict(
rangeselector=dict(
buttons=list([
dict(count=1,
label='1m',
step='month',
stepmode='backward'),
dict(count=6,
label='6m',
step='month',
stepmode='backward'),
dict(count=1,
label='YTD',
step='year',
stepmode='todate'),
dict(count=1,
label='1y',
step='year',
stepmode='backward'),
dict(step='all')
])
),
rangeslider=dict(
visible = True
),
type='date'
)
)
# Plot open, high, low, close for each coins
for c in dic.keys():
ohlc = dic[c][['open','high','low','close']].copy()
candlestick = go.Candlestick(x = ohlc.index,
open = ohlc['open'],
high = ohlc['high'],
low = ohlc['low'],
close = ohlc['close'],
name = 'OHLC')
fig = go.Figure(data = [candlestick],
layout = layout)
fig.update_yaxes(showgrid=True,
zeroline=False,
showticklabels=True,
showspikes=True,
spikemode='across',
spikesnap='cursor',
spikethickness=1,
showline=True,
spikedash='dot',
spikecolor="#707070",
autorange = True, # DOESN'T WORK....
fixedrange= False # DOESN'T WORK....
)
fig.update_xaxes(showgrid=True,
zeroline=False,
showticklabels=True,
showspikes=True,
spikemode='across',
spikesnap='cursor',
spikethickness=1,
showline=True,
spikedash='dot',
spikecolor="#707070",
type='date',
)
fig.update_layout(title = 'OHLC for: '+c,
height = 750,
plot_bgcolor="#FFFFFF",
hovermode="x",
hoverdistance=100,
spikedistance=1000,
xaxis_rangeslider_visible=True,
dragmode='pan',
)
fig.show()
I tried to use autorange = True
and fixedrange = False
but apparently that does nothing for reasons I donβt understand.
Thanks in advance for your help !