Made with Plotapi
You can create beautiful, interactive, and engaging visualisations like this one with Plotapi in any programming language.
from plotapi import Chord Chord.set_license("your username", "your license key")
Plotapi Chord supports animations - both for looping and for nice introductions to your visualisation.
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.
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 = ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]
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)
Animations can be controlled with the following parameters:
animated_loopwill result in an animation that loops forever, this is primarily useful in combination with the
to_mp4()end-point to create a looping video.
animated_introwill result in an animation that loops once, and serves as a nice introduction to your visualisation as it loads.
animated_durationdetermines how long a single loop will take.
Let's try both approaches.
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!
You may miss the first - you can refresh the page and scroll back down here to catch it!
Chord(matrix, names, wrap_labels=True, animated_intro=True, animated_duration=3000).show()
This next one will loop forever.
Chord(matrix, names, wrap_labels=True, animated_loop=True, animated_duration=3000).show()