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

Bipartite (Divided) Labels

Made with Plotapi

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

Preamble

In [1]:
from plotapi import Chord

Chord.set_license("your username", "your license key")

Introduction

It's often necessary to label either side of our bipartite Chord diagrams - Plotapi makes this easy.

As we can see, we have set our license details in the preamble with Chord.set_license()

Dataset

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

In [2]:
matrix = [
    [0, 0, 0, 1, 4, 1],
    [0, 0, 0, 1, 3, 2],
    [0, 0, 0, 1, 2, 2],
    [1, 1, 1, 0, 0, 0],
    [4, 3, 2, 0, 0, 0],
    [1, 2, 2, 0, 0, 0],
]

names = ["Right 1", "Right 2", "Right 3", "Left 3", "Left 2", "Left 1"]
colors = ["#7400B8", "#5E60CE", "#5684D6", "#56CFE1", "#64DFDF", "#80FFDB"]

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)
Out[3]:
Right 1 Right 2 Right 3 Left 3 Left 2 Left 1
Right 1 0 0 0 1 4 1
Right 2 0 0 0 1 3 2
Right 3 0 0 0 1 2 2
Left 3 1 1 1 0 0 0
Left 2 4 3 2 0 0 0
Left 1 1 2 2 0 0 0

Visualisation

To label both sides of the bipartite Chord diagram, we can set the bipartite_left_label and bipartite_right_label.

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, colors=colors, bipartite=True, bipartite_idx=3,
      bipartite_left_label="Left Side", 
      bipartite_right_label="Right Side").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 with Plotapi in any programming language.

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