Put text annotation as background in a scatterplot

You can define the text as a Scatter trace, mode= β€˜text’:


import plotly.graph_objects as go
import numpy as np


y=np.random.randint(1, 8, 5)
a, b = y.min(), y.max()

tr1=go.Scatter(x=np.arange(5),  y=y)
tr0=go.Scatter(x=[2], y=[(a+b)/2], mode='text', text='Background text', textposition='middle center',
               textfont_size=70, textfont_family='Sherif', textfont_color='rgba(50,50,50,0.5)', 
               showlegend=False)

fig=go.Figure(data=[tr0, tr1])

2 Likes