API for coders
Linked data table
PlotAPI Chord supports a linked data table. This means as you hover over arcs and chords in the Chord diagram, a data table will be filtering in real-time to show more information.
Sample data
Let’s import PlotAPI and load our sample data.
from plotapi import Chord
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"]
To make use of the linked data table, we need to provide some data in CSV format. This could be loaded through a file, directly in a string, or using a pandas DataFrame .to_csv(index=False)
.
data_table = """Genre 1,Genre 2,Awesome
Action,Thriller,The PlotAPI Horror
Action,Fantasy,Lord of the PlotAPI
Action,Thriller,Action for PlotAPI
Action,Drama,Feeling the PlotAPI
Action,Comedy,PlotAPI Turbo Force"""
Demonstration
We’ll enable the linked data table by passing data into the data_table
parameter, and we’ll modify the data_table_column_width
by setting it to a smaller value of 80.
Chord(
matrix,
names,
width=400,
margin=20,
curved_labels=True,
data_table=data_table,
data_table_column_width=80,
).show()
We’ve shrunk this demonstration
We’ve shrunk this demonstration to fit within the Docs content area. Under normal circumstances, it will have more room to breathe!