3
$\begingroup$

I've done some clustering, and now I want to visualise the relationships with some features. Ideally I want to create a chord diagram like the image below (source):

enter image description here

The chord graph basically shows the relationships between data from a matrix. E.g. in the image above, one observes that around 50% of the patients with a cough come from sub-phenotype 1 (which is one of the 3 clusters). This diagram is especially useful to quickly provide an overview of the different clusters and how the clusters are characterized (i.e. by which features).

However, this is currently not practical in Python since there is no library that supports this (see here) with the numbers around the circle. Are there any other visualisations that offer the same information, but are inherently totally different? I've searched for similar visualisations but could not find anything that offers the same information visually.

$\endgroup$
8
  • 1
    $\begingroup$ @Alexis my bad, I should've chosen other words. It obviously is technically possible, however current libraries do not support it. Edited the post. $\endgroup$
    – sander
    Mar 7, 2021 at 17:43
  • 1
    $\begingroup$ @Alexis thanks for the welcoming and your advice, I've edited the post again! $\endgroup$
    – sander
    Mar 7, 2021 at 17:54
  • 1
    $\begingroup$ It's pretty, but isn't it just an encoding of data from a 3 x 8 table that could go in a bar chart or dot chart? $\endgroup$
    – Nick Cox
    Mar 7, 2021 at 19:38
  • 1
    $\begingroup$ And the chord plot doesn’t get messier too? $\endgroup$
    – Nick Cox
    Mar 7, 2021 at 21:18
  • 2
    $\begingroup$ Posting the data behind the diagram would allow comparison of different kinds of graph. $\endgroup$
    – Nick Cox
    Mar 7, 2021 at 21:33

2 Answers 2

2
$\begingroup$

I agree with @Nick Cox. This figure is pretty, but doesn't seem very good to me except as eye candy. In essence, this is a Sankey plot (a.k.a., river plot or flow diagram) with just two levels where the ends have been bent into semicircles. If you're married to that, I would use a Sankey plot where the ends have not been bent into semicircles for easier readability. You can see an example of a Sankey plot (in R) in my answer to Chart suggestions for data flow. Apparently these can be made in Python using matplotlib.

However, I think you would do better to use a mosaic plot or a biplot from a correspondence analysis. I have an example of a mosaic plot in my answer to What's the best way to visualize the effects of categories & their prevalence in logistic regression?, and an example of plotting the results of a correspondence analysis in my answer to Which is the best visualization for contingency tables? Both mosaic plots and correspondence analyses can also be plotted with Python.

$\endgroup$
2
  • $\begingroup$ Sorry for the late reply. Thanks a lot, I'll definitely be using a few of those plots in my thesis. I'm currently working on visualizing the flows of patients between clusters over time, so the Sankey plot will be very useful as well :). $\endgroup$
    – sander
    May 11, 2021 at 10:20
  • $\begingroup$ You're welcome, @Sandertjuhh. $\endgroup$ May 11, 2021 at 11:29
2
$\begingroup$

Frame challenge: Use Python 3.6 or higher to create chord charts/chord diagrams

The Bokeh Python visualization library apparently provides a function chord_from_df() which produces (gorgeous) chord diagrams, such as this:

Example chord chart/chord diagram from the Bokeh user documentation website

Instructions for installing Bokeh for use with Python 3.6 and above.

PS Despite this answer being one which might suggest a close & migrate to Stackoverflow, Sandertjuhh's original question deserves attention here for its substantive interest in ways of communicating the same insights that one gleans from a chord chart/chord diagram.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks for the suggestion @Alexis. I've tried that library in Python which works, but does not provide the numbers around the circle. And neither do other Python libraries, unfortunately. For that reason I'm looking for other ways of visualizing the same information. $\endgroup$
    – sander
    Mar 7, 2021 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.