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

Multi-line Label Wrapping

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

Plotapi Chord labels wrap by default - this can be disabled if required.

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, 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 = ["Exciting Action", "Fun Adventure", "Hilarious Comedy", "Drama", "Fantasy", "Chilling Thriller"]

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]:
Exciting Action Fun Adventure Hilarious Comedy Drama Fantasy Chilling Thriller
Exciting Action 0 5 6 4 7 4
Fun Adventure 5 0 5 4 6 5
Hilarious Comedy 6 5 0 4 5 5
Drama 4 4 4 0 5 5
Fantasy 7 6 5 5 0 4
Chilling Thriller 4 5 5 5 4 0

Visualisation

Label wrapping is controlled with by the wrap_labels parameter which is True by default.

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 [6]:
Chord(matrix, names, colors="viridis").show()
Plotapi - Chord Diagram

Let's demonstrate label wrapping set to disabled.

In [7]:
Chord(matrix, names, colors="viridis", wrap_labels=False).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