Made with Plotapi
You can create beautiful, interactive, and engaging visualisations like this one with Plotapi in any programming language.
from plotapi import Chord Chord.set_license("your username", "your license key")
The asymmetric (
symmetric=False) Plotapi Chord diagram allows us to represent the value at each end of the relationship with a single ribbon. However, it may be more suitable to use two different ribbons with arrows to indicate the direction of the relationship. This is possible with Plotapi Chord.
As we can see, we have set our license details in the preamble with
Chord expects a list of names (
list[str]) and a co-occurence matrix (
list[list[float]]) as input.
matrix = [ [0, 5, 6, 4], [2, 0, 5, 4], [6, 5, 0, 4], [2, 4, 3, 0], ] names = ["Action", "Adventure", "Comedy", "Drama"]
It may look more clear if we present this as a table with the columns and indices labelled. This is entirely optional.
import pandas as pd pd.DataFrame(matrix, columns=names, index=names)
To enable directed mode, we only need to set the
directed parameter to
Here we're using
.show() which outputs to a Jupyter Notebook cell, however, we may want to output to a HTML file with
.to_html() instead. More on the different output methods later!
Be sure to interact with the visualisation to see what the default settings can do!
Chord(matrix, names, directed=True, colors="yellow_blue").show()
The directed Chord diagram can be paired with
reverse_gradients=True to make it easier to see where inbound/outbound relationships are coming from or going to.
Chord(matrix, names, directed=True, colors="yellow_blue", reverse_gradients=True).show()