Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Text on the middle of a line plot scatter


I would like to get a text on the middle of a line.
Until now, when I create a line, that put the text only on the start or the end point of the line. For more lisibility, I would like to put the text on the middle of the line.

Lines=plt.graph_objs.Scatter(x=ListCoordYe,y=ListCoordXe,mode=‘lines+text’,line=dict(color=‘rgb(210,210,210)’, width=10),text=ListRest,hoverinfo=‘text’,textposition=‘bottom’)

How to do it plz ?

Thanks !

Plotting text with your data (mode=‘text’) only allows the data to appear at your data points. To add text to your graph between your data points you could add an annotation:

Thanks for your answer. Indeed that work great ! But is there any possibility to get an hover on the middle of the line instead of a static text ?
And is there a way go get an scattergl plot with gl annotations ?

Unfortunately it is not possible to get hover in the middle of the line.
You may be able to hack around this by adding a transparent point w/ the hover information you wish to represent in the middle of your line, but as far as plotting a line goes, we don’t interpolate points to display hover information.