from plotapi import Chord Chord.set_license("your username", "your license key")
In a chord diagram (or radial network), entities are arranged radially as segments with their relationships visualised by arcs that connect them. The size of the segments illustrates the numerical proportions, whilst the size of the arc illustrates the significance of the relationships1. Check out this video on Chord Diagrams.
Chord diagrams are useful when trying to convey relationships between different entities, and they can be beautiful and eye-catching.
Click here to get access to the full-featured data visualization API, producing beautiful interactive visualizations, e.g. those featured on the front page of Reddit.
- Produce beautiful interactive Chord diagrams.
- Customize colours and font-sizes.
- Access Divided mode, enabling two sides to your diagram.
- Symmetric and Asymmetric modes,
- Add images and text on hover,
- Access finer-customisations including HTML injection.
- Allows commercial use without open source requirement.
The PlotAPI Package¶
With Python in mind, there are many libraries available for creating Chord diagrams, such as Plotly, Bokeh, and a few that are lesser-known. However, I wanted to find one that was as beautiful as it was interactive.
I couldn't find anything that ticked all the boxes, so I created PlotAPI. It took some time to get it perfect, but I wanted to hide away everything behind a single line of code. The tricky part was enabling multiple chord diagrams on the same page, and then loading resources in a way that would support Jupyter Notebooks.
You can get the package either from PyPi using
pip install plotapi and from the website. With your processed data, you should be able to plot something beautiful with just a single line,
The focus for this section will be the demonstration of the
chord package. To keep it simple, we will use synthetic data that illustrates the co-occurrences between movie genres within the same movie.
matrix = [ [0, 5, 6, 4, 7, 4], [5, 0, 5, 4, 6, 5], [6, 5, 0, 4, 5, 5], [4, 4, 4, 0, 5, 5], [7, 6, 5, 5, 0, 4], [4, 5, 5, 5, 4, 0], ] names = ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]
Chord(matrix, names, colors="set2").show()
Chord(matrix, names, colors="green_blue").show()
Chord(matrix, names, colors="set3").show()
Chord(matrix, names, colors="purple_red").show()
Chord(matrix, names, colors=f"yellow_green").show()
hex_colours = ["#222222", "#333333", "#4c4c4c", "#666666", "#848484", "#9a9a9a"] Chord(matrix, names, colors=hex_colours).show()
Chord(matrix, names, curved_labels=True, label_color="#4c40bf").show()
Chord(matrix, names, opacity=0.1).show()
In this section, we've introduced the chord diagram and
chord package. We used the package and some synthetic data to demonstrate several chord diagram visualisations with different configurations. The chord Python package is available for free using
pip install plotapi.
Tintarev, N., Rostami, S., & Smyth, B. (2018, April). Knowing the unknown: visualising consumption blind-spots in recommender systems. In Proceedings of the 33rd Annual ACM Symposium on Applied Computing (pp. 1396-1399). ↩