Hi @abhinavk welcome to the forums.
You could use the text
argument:
import plotly.graph_objects as go
import numpy as np
fig = go.Figure()
for fac, txt in enumerate('ABCDE'):
fig.add_scatter(
x=np.arange(1, 10),
y=np.arange(1, 10) + 10*fac,
mode='text+lines',
text=txt,
name=f'trace_{txt}')
fig.show()
creates: