Introduction to Data Visualization with Plotly in Python
Alex Scriven
Data Scientist
$$

$$
add_annotation()$$
update_layout() and the annotations argumenttext - The actual text to be displayed$$
x and y: specify the location of the annotation$$
showarrow = True/False - used to include an arrow$$
🛑 Be careful placing annotations absolutely - if your data changes, things may overlap
x and y refer to the data values in the plot$$
xref and yref to paper to position annotations absolutelyx and y are percentages from 0 to 1 across the plot areax=0.5, y=0.5) would be in the center of the plot
my_annotation = dict( x=215111, y=449000,showarrow=True, arrowhead=3,text="Our company is doing well", font=dict(size=10, color="black") )fig.update_layout(annotations=[my_annotation]) fig.show()
$$

$$
float_annotation = dict( xref="paper", yref="paper",x=0.5, y=0.8,showarrow=False, text="You should <b>BUY</b>", font=dict(size=15, color="black"), bgcolor="rgb(255,0,0)" )

Introduction to Data Visualization with Plotly in Python