'How to add data labels to plotly line graph?

I've got a simple plotly line graph:

import plotly.express as px
fig = px.line(data, x="x-axis", y="variable")
fig.show()

plotly line graph

I want to add data labels displaying each y-axis value to each point, but I can't work out how to do it using the plotly api. Is it possible? Can anyone point out how?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source