I am using Plotly in python to generate figures. As in the title, I cannot update figure annotations with the update_annotations function.
The following is an example of multiplot.
data = pd.DataFrame(np.random.rand(10,3), columns=['A', 'B', 'C'], index=pd.date_range(start='2001-01-01', periods=10))
fig = make_subplots(rows=3, cols=1, subplot_titles=['Top','Middle', 'Bottom'])
fig.add_trace(go.Scatter(x=data.index, y=data['A'], mode='lines'), row=1, col=1)
fig.add_trace(go.Scatter(x=data.index, y=data['B'], mode='lines'), row=2, col=1)
fig.add_trace(go.Scatter(x=data.index, y=data['C'], mode='lines'), row=3, col=1)
I can change the name of the top figure from 'TOP' to 'TOP_TEST' and its position with the following code.
fig['layout']['annotations'][0]['text'] = 'TOP_TEST'
fig['layout']['annotations'][0]['x'] = 0.02
However, I do not understand why I cannot do the same with the function update_annotations. If it works, it seems to be much easier to change multiple parameters at once.
fig.update_annotations(row=1, col=1, text='TOP_TEST', x=0.02)
Thank you for any comment in advance.