Engaging plots, made easy.

Easily turn your data into engaging visualizations. Powerful API for coders. Powerful app for everyone.

main.py
notebook.ipynb
main.rs
from plotapi import Chord

Chord(matrix, names).show()

Visualizations Sankey

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 Sankey

links = [
    {"source":"Group A", "target":"Rank 1", "value": 1000},
    {"source":"Group B", "target":"Rank 1", "value": 300},
    {"source":"Group B", "target":"Rank 2", "value": 600},
    {"source":"Group B", "target":"Rank 3", "value": 400},
    {"source":"Rank 1", "target":"Club A", "value": 700},
    {"source":"Rank 1", "target":"Club B", "value": 400},
    {"source":"Rank 1", "target":"Club C", "value": 200},
    {"source":"Rank 2", "target":"Club B", "value": 200},
    {"source":"Rank 2", "target":"Club C", "value": 400},
    {"source":"Rank 3", "target":"Withdrawn", "value": 400},
    {"source":"Club A", "target":"The Most Amazing Prize", "value": 500},
]

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 = '''Start,Destination,TV Rating,Image
,,9.0,<img src='https://datacrayon.com/images/data-is-beautiful/pokemon_thumbs/101.png'>
Group A,Rank 1,6.0,<img src='https://datacrayon.com/images/data-is-beautiful/pokemon_thumbs/192.png'>
Group A,Rank 1,5.0,<img src='https://datacrayon.com/images/data-is-beautiful/pokemon_thumbs/213.png'>'''

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.

Here we're using .show() which outputs to a Jupyter Notebook cell, however, we may want to output to an 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! Try hovering over Group A and its link to Rank 1.

The data table mode includes the "locking" feature. Try clicking on the Group A node and you will see a padlock icon appear in the top right, and until you click somewhere again the current selection will persist.

Sankey(
    links,
    width=400,
    height=400,
    link_numbers=False,
    horizontal_labels_at_shallowest=False,
    horizontal_labels_at_deepest=False,
    data_table=data_table,
    data_table_column_width=70,
).show()
PlotAPI - Sankey Diagram

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!

Previous
Sankey