Engaging plots, made easy.

Easily turn your data into engaging visualizations. Powerful API for coders. Powerful app for everyone.

main.py
notebook.ipynb
main.rs
from plotapi import Chord

Chord(matrix, names).show()

API for coders

Equal-sized arcs

The arcs of a Chord diagram can be customised to be of equal size, regardless of the value of their relationships.


Sample data

Let’s import PlotAPI and load our sample data.

from plotapi import Chord

names = ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]

Demonstration

It may be desirable to have equal-sized segments in our Chord Diagram. This is possible with PlotAPI, and makes use of the colored_diagonals feature.

Setting up

The idea is to determine the max frequency in our plot, and set all the diagonals to that value. Let’s assume the max frquency is 20 for this example.

matrix = [
    [20, 0, 0, 0, 0, 0],
    [0, 20, 0, 0, 0, 0],
    [0, 0, 20, 0, 0, 0],
    [0, 0, 0, 20, 0, 0],
    [0, 0, 0, 0, 20, 0],
    [0, 0, 0, 0, 0, 20],
]

Chord(matrix, names, title="Diagonals not coloured", 
      colored_diagonals=False).show()
PlotAPI - Chord Diagram

We can see above that this creates a chord diagram with equal-sized segments.

Populating our relationships

All we need to do now is introduce our relationships, and subtract them from the corresponding diagonal value.

matrix = [
    [11, 4, 5, 0, 0, 0],
    [4, 14, 2, 0, 0, 0],
    [5, 2, 13, 0, 0, 0],
    [0, 0, 0, 20, 0, 0],
    [0, 0, 0, 0, 20, 0],
    [0, 0, 0, 0, 0, 20],
]

With our matrix prepared, we can use Plotapi with colored_diagonals=False to create a diagram with equal-sized segments and some ribbons between categories. We could add some padding to separate them too.

Chord(matrix, names, colors="league",
      colored_diagonals=False, padding=0.2).show()
Previous
Chord