from plotapi import Chord Chord.set_license("your username", "your license key")
By default, Plotapi Chord displays occurrences where a category is not related to another category. These values appear in the diagonal of the matrix. It may be desirable to hide (but not remove) these values, this is possible with Plotapi.
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.
names=['one','two','three','four','five','six'] matrix = [ [19, 5, 6, 4, 7, 4], [5, 4, 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], ]
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)
The representation of the diagonal values can be hidden by setting
Let's first see what they look like when they're visible.
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, title="Diagonals coloured").show()
Now let's see what it looks like when they're not visible.
Chord(matrix, names, title="Diagonals not coloured", colored_diagonals=False).show()