Adding labels to a chord diagram

Hi,

I’m fairly new to Plotly and still trying to get the hang of it. I’m now trying to create a chord diagram with my own data, based on https://nbviewer.jupyter.org/github/empet/Plotly-plots/blob/master/Chord-diagram.ipynb?flush_cache=true.

While I can get a chord diagram using my own data, I would also like to add labels next to the ‘slices’ in a similar fashion as shown in https://moderndata.plot.ly/filled-chord-diagram-in-r-using-plotly/ (at the bottom). In the R example of the Plotly library I see there is a function called ‘add_text’, which I cannot find in the Python version of the library.

I tried using annotations in the make_layout function, but while this does add text, it is not possible to position the text and it also crops the image.

Does anybody have any clue as how to achieve this seemingly simple task of adding slice labels?

Hi @Timmolleman,

See https://plot.ly/python/text-and-annotations/#simple-annotation for an example of positioning annotation text in data coordinates (which is what I think you’ll want since the chord diagram args are defined as scatter traces). Note the xref and yref properties.

Another option is to use a scatter trace to display text like https://plot.ly/python/text-and-annotations/#adding-text-to-data-in-line-and-scatter-plots. You can set the scatter.mode property to 'text'to avoid displaying points or lines as well.

Hope that helps!
-Jon

Hello,
Has there been any progress with this? I wondered whether there was now a simpler way to add labels to the outer edges of a chord digram in plotly? I am confused how to write a function such that the labels will be automatically added to each segment.

Thank you in advance for any help!