Plotapi, beautiful by default.

Let plotapi do the heavy lifting – enabling beautiful interactive visualisations with a single line of code (instead of hundreds).

Get Plotapi

Directed Chord Diagrams


In [ ]:
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.set_license()


Chord expects a list of names (list[str]) and a co-occurence matrix (list[list[float]]) as input.

In [ ]:
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.

In [3]:
import pandas as pd
pd.DataFrame(matrix, columns=names, index=names)
Action Adventure Comedy Drama
Action 0 5 6 4
Adventure 2 0 5 4
Comedy 6 5 0 4
Drama 2 4 3 0


To enable directed mode, we only need to set the directed parameter to true.

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!

In [7]:
Chord(matrix, names, directed=True, colors="yellow_blue").show()
Plotapi - Chord Diagram

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.

In [6]:
Chord(matrix, names, directed=True, colors="yellow_blue", reverse_gradients=True).show()
Plotapi - Chord Diagram

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation. and the Plotapi Gallery.

Made with Plotapi

You can create beautiful, interactive, and engaging visualisations like this one in any programming language with Plotapi.

Get the Books

Enjoying these notebooks and want more on the subject? Check out the practical books on Data Science, Visualisation, and Evolutionary Algorithms.

Get the books