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()

API for coders

Animation

The BarFight animation can be modified to improve the presentation of our diagram, giving us control over animations durations, delays, and behavior.


Sample data

Let’s import PlotAPI and load our sample data.

from plotapi import BarFight

samples = [
    {"order": 0, "name": "Sankey", "value": 10},
    {"order": 0, "name": "Terminus", "value": 12},
    {"order": 0, "name": "Chord", "value": 8},
    {"order": 0, "name": "Bar Fight", "value": 9},
    {"order": 0, "name": "Pie Fight", "value": 12},

    {"order": 1, "name": "Sankey", "value": 18},
    {"order": 1, "name": "Terminus", "value": 24},
    {"order": 1, "name": "Chord", "value": 22},
    {"order": 1, "name": "Bar Fight", "value": 14},
    {"order": 1, "name": "Pie Fight", "value": 17},

    {"order": 2, "name": "Sankey", "value": 24},
    {"order": 2, "name": "Terminus", "value": 40},
    {"order": 2, "name": "Chord", "value": 32},
    {"order": 2, "name": "Bar Fight", "value": 19},
    {"order": 2, "name": "Pie Fight", "value": 42},

    {"order": 3, "name": "Sankey", "value": 32},
    {"order": 3, "name": "Terminus", "value": 62},
    {"order": 3, "name": "Chord", "value": 40},
    {"order": 3, "name": "Bar Fight", "value": 25},
    {"order": 3, "name": "Pie Fight", "value": 64},

    {"order": 4, "name": "Sankey", "value": 32},
    {"order": 4, "name": "Terminus", "value": 75},
    {"order": 4, "name": "Chord", "value": 55},
    {"order": 4, "name": "Bar Fight", "value": 45},
    {"order": 4, "name": "Pie Fight", "value": 120},
]

Demonstration

There are many opportunities to customise the BarFight animation. Let’s explore some of these in the upcoming sections.

Interval

The interval parameter controls the time it takes to transition between samples. A higher value results in a slower animation, whilst one closer to zero results in a faster animation. The default value is 2000.

Let’s demonstrate a slower BarFight animation.

BarFight(samples, interval=5000).show()

Now, let’s demonstrate a faster BarFight animation.

BarFight(samples, interval=500).show()
PlotAPI - Bar Fight Diagram

Order duration

The order_duration parameter controls the time it takes to re-order the order of bars. A higher value results in a slower re-ordering, whilst one closer to zero results in faster re-ordering. The default value is 500.

Let’s demonstrate slower re-ordering.

BarFight(samples, order_duration=1000).show()
PlotAPI - Bar Fight Diagram

Let’s demonstrate instant re-ordering.

BarFight(samples, order_duration=0).show()
PlotAPI - Bar Fight Diagram

Axis transition duration

The axis_transition_duration parameter controls the time it takes for the x-axis presentation to catch up with the current domain. A higher value results in a slower catch-up, whilst one closer to zero results in faster catch-up. The default value is 250.

Let’s demonstrate an instant catch-up.

BarFight(samples, axis_transition_duration=0).show()
PlotAPI - Bar Fight Diagram

Show restart button on animation end

The show_restart parameter controls whether the restart button is given focus at the end of the animation. The default value is True.

Let’s demonstrate it set to False.

BarFight(samples, show_restart=False).show()
PlotAPI - Bar Fight Diagram
Previous
Bar Fight