Getting started with Plotapi Pareto Front

Preamble

In [1]:
from plotapi import ParetoFront

ParetoFront.set_license("your username", "your license key")

Introduction

Our first Plotapi Pareto Front Diagram!

Plotapi Pareto Front is a beautiful and feature rich take on non-dominated sorting over time. As we can see, we have set our license details in the preamble with ParetoFront.set_license().

Dataset

Plotapi Pareto Front expects at minimum a list of dictionary items, these will define bi-objective solutions over time.

In [2]:
samples = [
    {'order': 20200101, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200101, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200101, 'objv_1': 40, 'objv_2': 12},   

    {'order': 20200104, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200104, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200104, 'objv_1': 40, 'objv_2': 14},   

    {'order': 20200109, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200109, 'objv_1': 45, 'objv_2': 12},   
    {'order': 20200109, 'objv_1': 45, 'objv_2': 10},   

    {'order': 20200112, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200112, 'objv_1': 50, 'objv_2': 11},   
    {'order': 20200112, 'objv_1': 50, 'objv_2': 10},   

    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   

    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   

    {'order': 20200120, 'objv_1': 60, 'objv_2': 8},   
    {'order': 20200120, 'objv_1': 60, 'objv_2': 8},   
    {'order': 20200120, 'objv_1': 60, 'objv_2': 8},   

    {'order': 20200123, 'objv_1': 60, 'objv_2': 8},   
    {'order': 20200123, 'objv_1': 60, 'objv_2': 8},   
    {'order': 20200123, 'objv_1': 60, 'objv_2': 8},   

    {'order': 20200123, 'objv_1': 80, 'objv_2': 3},  

    {'order': 20200123, 'objv_1': 30, 'objv_2': 20},  

    {'order': 20200125, 'objv_1': 30, 'objv_2': 20},  
    {'order': 20200125, 'objv_1': 10, 'objv_2': 20}, 

    {'order': 20200129, 'objv_1': 120, 'objv_2': 50},  
    {'order': 20200129, 'objv_1': 50, 'objv_2': 120},   
    {'order': 20200129, 'objv_1': 50, 'objv_2': 120},   
    {'order': 20200129, 'objv_1': 50, 'objv_2': 120},    

    {'order': 20200130, 'objv_1': 100, 'objv_2': 100},      
]

We can see that each dictionary item has three properties:

  • order which determines with time period this item belongs to. This should be numerical, but can be formatted e.g. as dates.
  • objv_1 the first objective value, e.g. "weight".
  • objv_2 the second objective value, e.g. "reps".

We can also populate the events structure to present event text at specific times.

In [3]:
events = [
    {
        "order": 20200101,
        "event": "My first ever gym visit!"
    },
    {
        "order": 20200109,
        "event": "I went a little heavier today!"
    },
    {
        "order": 20200120,
        "event": "Three solid sets of 60 kg!"
    },
    {
        "order": 20200129,
        "event": "Broke some records today!"
    }
]

Visualisation

Creating our first Pareto Front Diagram is as easy as calling Plotapi with our one input.

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!

In [4]:
ParetoFront(samples, events=events, title="Bench Press",
            objv_1_unit=" kg", objv_2_unit=" reps",
            x_label="Weight(kg)", y_label="Reps").show()
Plotapi - ParetoFront Diagram

Here we can see the default behaviour of Plotapi Pareto Front.

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

Displaying Event Information

Preamble

In [ ]:
from plotapi import LineFight

LineFight.set_license("your username", "your license key")

Introduction

Let's take a look at how we can display event content during our visualisation at different times. This can be useful for displaying additional information or images that are relevant to specific events.

Plotapi Line Fight is a beautiful and feature rich take on the popular Line Chart Race. As we can see, we have set our license details in the preamble with LineFight.set_license().

Dataset

Plotapi Line Fight expects at minimum a list of dictionary items, these will define the value of our segments over time.

In [ ]:
samples = [
    {"order": 0, "name": "Sankey", "value": 10},
    {"order": 0, "name": "Terminus", "value": 10},
    {"order": 0, "name": "Chord", "value": 40},
    {"order": 0, "name": "Bar Fight", "value": 90},
    {"order": 0, "name": "Pie Fight", "value": 70},

    {"order": 1, "name": "Sankey", "value": 30},
    {"order": 1, "name": "Terminus", "value": 20},
    {"order": 1, "name": "Chord", "value": 40},
    {"order": 1, "name": "Bar Fight", "value": 120},
    {"order": 1, "name": "Pie Fight", "value": 55},

    {"order": 2, "name": "Sankey", "value": 35},
    {"order": 2, "name": "Terminus", "value": 45},
    {"order": 2, "name": "Chord", "value": 60},
    {"order": 2, "name": "Bar Fight", "value": 85},
    {"order": 2, "name": "Pie Fight", "value": 100},

    {"order": 3, "name": "Sankey", "value": 25},
    {"order": 3, "name": "Terminus", "value": 60},
    {"order": 3, "name": "Chord", "value": 90},
    {"order": 3, "name": "Bar Fight", "value": 50},
    {"order": 3, "name": "Pie Fight", "value": 105},

    {"order": 4, "name": "Sankey", "value": 60},
    {"order": 4, "name": "Terminus", "value": 80},
    {"order": 4, "name": "Chord", "value": 120},
    {"order": 4, "name": "Bar Fight", "value": 30},
    {"order": 4, "name": "Pie Fight", "value": 95},
]

We can see that each dictionary item has three properties:

  • order which determines with time period this item belongs to. This should be numerical, but can be formatted e.g. as dates.
  • name the name of the item, and the text that appears on the line.
  • value the value of the line at the associated point in time.

Next, we'll start specifying event content to appear at certain points during our visualisation. Plotapi Line Fight expects a list of dictionary items to configure each event.

In [ ]:
events = [
    {
        "order": 0,
        "event": '<p>Event information content can be <b>formatted with HTML</b>!</p><p>You can even include CSS - the <a href ="https://plotapi.com">power</a> of both are available.</p>'
    },
    {
        "order": 1,
        "event": '<b>Something Special</b><br><img src="https://datacrayon.com/datasets/pokemon_img/150.png"><p>Something special happened here, probably!</p>'
    },
    {
        "order": 4,
        "event": '<p>By specifying a <b>duration</b>, an event can be displayed for longer than the default value - much like this one!</p>',
        "duration": 10000
    }
]

We can see that each dictionary item has three properties:

  • order, which determines with time period this event belongs to. This should correspond to the orders specified in the samples.
  • event, the HTML content of the event information popup.
  • duration, the maximum display duration for the corresponding event content.

By default, a Plotapi Line Fight visualisation will pause for the duration of an event. However, it can be configured to either continue running or wait for the user to press a continue button. Check the next section in the Plotapi Gallery for an example!

Visualisation

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!

In [10]:
LineFight(samples, event_pause=False,
         events=events).show()
Plotapi - Line Fight Diagram

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

Changing the Colours and Icons

Preamble

In [1]:
from plotapi import LineFight

LineFight.set_license("your username", "your license key")

Introduction

Let's take a look at how we can change the colours and icons for nodes in our Line Fight diagram.

Plotapi Line Fight is a beautiful and feature rich take on the popular Line Chart Race. As we can see, we have set our license details in the preamble with LineFight.set_license().

Dataset

Plotapi Line Fight expects at minimum a list of dictionary items, these will define the value of our segments over time.

In [2]:
samples = [
    {"order": 0, "name": "Sankey", "value": 10},
    {"order": 0, "name": "Terminus", "value": 10},
    {"order": 0, "name": "Chord", "value": 40},
    {"order": 0, "name": "Bar Fight", "value": 90},
    {"order": 0, "name": "Pie Fight", "value": 70},

    {"order": 1, "name": "Sankey", "value": 30},
    {"order": 1, "name": "Terminus", "value": 20},
    {"order": 1, "name": "Chord", "value": 40},
    {"order": 1, "name": "Bar Fight", "value": 120},
    {"order": 1, "name": "Pie Fight", "value": 55},

    {"order": 2, "name": "Sankey", "value": 35},
    {"order": 2, "name": "Terminus", "value": 45},
    {"order": 2, "name": "Chord", "value": 60},
    {"order": 2, "name": "Bar Fight", "value": 85},
    {"order": 2, "name": "Pie Fight", "value": 100},

    {"order": 3, "name": "Sankey", "value": 25},
    {"order": 3, "name": "Terminus", "value": 60},
    {"order": 3, "name": "Chord", "value": 90},
    {"order": 3, "name": "Bar Fight", "value": 50},
    {"order": 3, "name": "Pie Fight", "value": 105},

    {"order": 4, "name": "Sankey", "value": 60},
    {"order": 4, "name": "Terminus", "value": 80},
    {"order": 4, "name": "Chord", "value": 120},
    {"order": 4, "name": "Bar Fight", "value": 30},
    {"order": 4, "name": "Pie Fight", "value": 95},
]

We can see that each dictionary item has three properties:

  • order which determines with time period this item belongs to. This should be numerical, but can be formatted e.g. as dates.
  • name the name of the item, and the text that appears on the element.
  • value the value of the element at the associated point in time.

Next, we'll start customising the elements, or nodes, that will represent our data over time. Plotapi Line Fight expects a list of dictionary items to configure each node.

In [3]:
nodes = [
    {
        "name": "Sankey",
        "color": "#ffd166", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/003.png"
    },
    {
        "name": "Terminus",
        "color": "#06d6a0", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/004.png"
    },
    {
        "name": "Chord",
        "color": "#118ab2", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/025.png"
    },
    {
        "name": "Bar Fight",
        "color": "#073b4c", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/151.png"
    },
    {
        "name": "Pie Fight",
        "color": "#ef476f", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/232.png"
    }
]

We can see that each dictionary item has three properties:

  • name, the name of the item, which corresponds to names specified in the samples definitions above.
  • color, the desired colour of the elements (CSS colour e.g. "#073b4c" or "red").
  • icon, the location of the image to use for the icon.

Visualisation

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!

In [4]:
LineFight(samples,
         nodes=nodes).show()
Plotapi - Line Fight Diagram

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

Getting started with Plotapi Line Fight

Preamble

In [1]:
from plotapi import LineFight

LineFight.set_license("your username", "your license key")

Introduction

Our first Plotapi Line Fight Diagram!

Plotapi Line Fight is a beautiful and feature rich take on the popular Line Chart Race. As we can see, we have set our license details in the preamble with LineFight.set_license().

Dataset

Plotapi Line Fight expects at minimum a list of dictionary items, these will define the value of our lines over time.

In [2]:
samples = [
    {"order": 0, "name": "Sankey", "value": 10},
    {"order": 0, "name": "Terminus", "value": 10},
    {"order": 0, "name": "Chord", "value": 40},
    {"order": 0, "name": "Bar Fight", "value": 90},
    {"order": 0, "name": "Pie Fight", "value": 70},

    {"order": 1, "name": "Sankey", "value": 30},
    {"order": 1, "name": "Terminus", "value": 20},
    {"order": 1, "name": "Chord", "value": 40},
    {"order": 1, "name": "Bar Fight", "value": 120},
    {"order": 1, "name": "Pie Fight", "value": 55},

    {"order": 2, "name": "Sankey", "value": 35},
    {"order": 2, "name": "Terminus", "value": 45},
    {"order": 2, "name": "Chord", "value": 60},
    {"order": 2, "name": "Bar Fight", "value": 85},
    {"order": 2, "name": "Pie Fight", "value": 100},

    {"order": 3, "name": "Sankey", "value": 25},
    {"order": 3, "name": "Terminus", "value": 60},
    {"order": 3, "name": "Chord", "value": 90},
    {"order": 3, "name": "Bar Fight", "value": 50},
    {"order": 3, "name": "Pie Fight", "value": 105},

    {"order": 4, "name": "Sankey", "value": 60},
    {"order": 4, "name": "Terminus", "value": 80},
    {"order": 4, "name": "Chord", "value": 120},
    {"order": 4, "name": "Bar Fight", "value": 30},
    {"order": 4, "name": "Pie Fight", "value": 95},
]

We can see that each dictionary item has three properties:

  • order which determines with time period this item belongs to. This should be numerical, but can be formatted e.g. as dates.
  • name the name of the item, and the text that appears on the lines.
  • value the value of the lines at the associated point in time.

Visualisation

Creating our first Line Fight Diagram is as easy as calling Plotapi with our one input.

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!

In [3]:
LineFight(samples).show()
Plotapi - Line Fight Diagram

Here we can see the default behaviour of Plotapi Line Fight.

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

Event Information Modes

Preamble

In [1]:
from plotapi import BarFight

BarFight.set_license("your username", "your license key")

Introduction

Let's take a look at how we can change the colours and icons for nodes in our Bar Fight diagram.

Plotapi Bar Fight is a beautiful and feature rich take on the popular Bar Chart Race. As we can see, we have set our license details in the preamble with BarFight.set_license().

Dataset

Plotapi Bar Fight expects at minimum a list of dictionary items, these will define the value of our segments over time.

In [2]:
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": 38},
    {"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},
]

Next, we'll start specifying event content to appear at certain points during our visualisation. Plotapi Bar Fight expects a list of dictionary items to configure each event.

In [3]:
events = [
    {
        "order": 0,
        "event": '<p>Event information content can be <b>formatted with HTML</b>!</p><p>You can even include CSS - the <a href ="https://plotapi.com">power</a> of both are available.</p>'
    },
    {
        "order": 1,
        "event": '<b>Something Special</b><br><img src="https://datacrayon.com/datasets/pokemon_img/150.png"><p>Something special happened here, probably!</p>'
    },
    {
        "order": 4,
        "event": '<p>By specifying a <b>duration</b>, an event can be displayed for longer than the default value - much like this one!</p>',
    }
]

Visualisation

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!

Default Event Mode

Without any additional configuration, the default event mode will pause the visualisation for the event duration.

This duration is specified either per-event using the events structure above, or globally using the event_duration parameter as seen below.

In [4]:
BarFight(samples,
         events=events,
         event_duration=7500).show()
Plotapi - Bar Fight Diagram

Running Event Mode

By specifying event_pause=False, we can keep the visualisation running during the duration of the event content.

In this mode, the event duration is treated as a maximum duration, such that any subsequent events will interrupt the previous one.

In [5]:
BarFight(samples,
         events=events,
         event_pause=False).show()
Plotapi - Bar Fight Diagram

Interactive Event Mode

By specifying auto_proceed=False, we can pause the visualisation and require user interaction for it to continue, i.e. clicking the continue button.

In [6]:
BarFight(samples,
         events=events,
         auto_proceed=False).show()
Plotapi - Bar Fight Diagram

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

Event Information Modes

Preamble

In [1]:
from plotapi import PieFight

PieFight.set_license("your username", "your license key")

Introduction

Let's take a look at changing how the event information is displayed during a Pie Fight diagram.

Plotapi Pie Fight is a beautiful and feature rich take on the popular Pie Chart Race. As we can see, we have set our license details in the preamble with PieFight.set_license().

Dataset

Plotapi Pie Fight expects at minimum a list of dictionary items, these will define the value of our segments over time.

In [2]:
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": 38},
    {"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},
]

Next, we'll start specifying event content to appear at certain points during our visualisation. Plotapi Pie Fight expects a list of dictionary items to configure each event.

In [3]:
events = [
    {
        "order": 0,
        "event": '<p>Event information content can be <b>formatted with HTML</b>!</p><p>You can even include CSS - the <a href ="https://plotapi.com">power</a> of both are available.</p>'
    },
    {
        "order": 1,
        "event": '<b>Something Special</b><br><img src="https://datacrayon.com/datasets/pokemon_img/150.png"><p>Something special happened here, probably!</p>'
    },
    {
        "order": 4,
        "event": '<p>By specifying a <b>duration</b>, an event can be displayed for longer than the default value - much like this one!</p>',
    }
]

Visualisation

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!

Default Event Mode

Without any additional configuration, the default event mode will pause the visualisation for the event duration.

This duration is specified either per-event using the events structure above, or globally using the event_duration parameter as seen below.

In [4]:
PieFight(samples,
         events=events,
         event_duration=7500).show()
Plotapi - Pie Fight Diagram

Running Event Mode

By specifying event_pause=False, we can keep the visualisation running during the duration of the event content.

In this mode, the event duration is treated as a maximum duration, such that any subsequent events will interrupt the previous one.

In [5]:
PieFight(samples,
         events=events,
         event_pause=False).show()
Plotapi - Pie Fight Diagram

Interactive Event Mode

By specifying auto_proceed=False, we can pause the visualisation and require user interaction for it to continue, i.e. clicking the continue button.

In [6]:
PieFight(samples,
         events=events,
         auto_proceed=False).show()
Plotapi - Pie Fight Diagram

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

Displaying Event Information

Preamble

In [1]:
from plotapi import BarFight

BarFight.set_license("your username", "your license key")

Introduction

Let's take a look at how we can display event content during our visualisation at different times. This can be useful for displaying additional information or images that are relevant to specific events.

Plotapi Bar Fight is a beautiful and feature rich take on the popular Bar Chart Race. As we can see, we have set our license details in the preamble with BarFight.set_license().

Dataset

Plotapi Bar Fight expects at minimum a list of dictionary items, these will define the value of our segments over time.

In [2]:
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": 38},
    {"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},
]

We can see that each dictionary item has three properties:

  • order which determines with time period this item belongs to. This should be numerical, but can be formatted e.g. as dates.
  • name the name of the item, and the text that appears on the bar.
  • value the value of the bar at the associated point in time.

Next, we'll start specifying event content to appear at certain points during our visualisation. Plotapi Bar Fight expects a list of dictionary items to configure each event.

In [3]:
events = [
    {
        "order": 0,
        "event": '<p>Event information content can be <b>formatted with HTML</b>!</p><p>You can even include CSS - the <a href ="https://plotapi.com">power</a> of both are available.</p>'
    },
    {
        "order": 1,
        "event": '<b>Something Special</b><br><img src="https://datacrayon.com/datasets/pokemon_img/150.png"><p>Something special happened here, probably!</p>'
    },
    {
        "order": 4,
        "event": '<p>By specifying a <b>duration</b>, an event can be displayed for longer than the default value - much like this one!</p>',
        "duration": 10000
    }
]

We can see that each dictionary item has three properties:

  • order, which determines with time period this event belongs to. This should correspond to the orders specified in the samples.
  • event, the HTML content of the event information popup.
  • duration, the maximum display duration for the corresponding event content.

By default, a Plotapi Bar Fight visualisation will pause for the duration of an event. However, it can be configured to either continue running or wait for the user to press a continue button. Check the next section in the Plotapi Gallery for an example!

Visualisation

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!

In [4]:
BarFight(samples,
         events=events).show()
Plotapi - Bar Fight Diagram

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

Displaying Event Information

Preamble

In [ ]:
from plotapi import PieFight

PieFight.set_license("your username", "your license key")

Introduction

Let's take a look at how we can display event content during our visualisation at different times. This can be useful for displaying additional information or images that are relevant to specific events.

Plotapi Pie Fight is a beautiful and feature rich take on the popular Pie Chart Race. As we can see, we have set our license details in the preamble with PieFight.set_license().

Dataset

Plotapi Pie Fight expects at minimum a list of dictionary items, these will define the value of our segments over time.

In [ ]:
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": 38},
    {"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},
]

We can see that each dictionary item has three properties:

  • order, which determines with time period this item belongs to. This should be numerical, but can be formatted e.g. as dates.
  • name, the name of the item, and the text that appears on the pie chart segment.
  • value, the value of the segment at the associated point in time.

Next, we'll start specifying event content to appear at certain points during our visualisation. Plotapi Pie Fight expects a list of dictionary items to configure each event.

In [ ]:
events = [
    {
        "order": 0,
        "event": '<p>Event information content can be <b>formatted with HTML</b>!</p><p>You can even include CSS - the <a href ="https://plotapi.com">power</a> of both are available.</p>'
    },
    {
        "order": 1,
        "event": '<b>Something Special</b><br><img src="https://datacrayon.com/datasets/pokemon_img/150.png"><p>Something special happened here, probably!</p>'
    },
    {
        "order": 4,
        "event": '<p>By specifying a <b>duration</b>, an event can be displayed for longer than the default value - much like this one!</p>',
        "duration": 10000
    }
]

We can see that each dictionary item has three properties:

  • order, which determines with time period this event belongs to. This should correspond to the orders specified in the samples.
  • event, the HTML content of the event information popup.
  • duration, the maximum display duration for the corresponding event content.

By default, a Plotapi Pie Fight visualisation will pause for the duration of an event. However, it can be configured to either continue running or wait for the user to press a continue button. Check the next section in the Plotapi Gallery for an example!

Visualisation

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!

In [8]:
PieFight(samples,
         events=events).show()
Plotapi - Pie Fight Diagram

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

Changing the Colours and Icons

Preamble

In [1]:
from plotapi import BarFight

BarFight.set_license("your username", "your license key")

Introduction

Let's take a look at how we can change the colours and icons for nodes in our Bar Fight diagram.

Plotapi Bar Fight is a beautiful and feature rich take on the popular Bar Chart Race. As we can see, we have set our license details in the preamble with BarFight.set_license().

Dataset

Plotapi Bar Fight expects at minimum a list of dictionary items, these will define the value of our segments over time.

In [2]:
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},
]

We can see that each dictionary item has three properties:

  • order which determines with time period this item belongs to. This should be numerical, but can be formatted e.g. as dates.
  • name the name of the item, and the text that appears on the bar.
  • value the value of the bar at the associated point in time.

Next, we'll start customising the bars, or nodes, that will represent our data over time. Plotapi Bar Fight expects a list of dictionary items to configure each node.

In [3]:
nodes = [
    {
        "name": "Sankey",
        "color": "#ffd166", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/003.png"
    },
    {
        "name": "Terminus",
        "color": "#06d6a0", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/004.png"
    },
    {
        "name": "Chord",
        "color": "#118ab2", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/025.png"
    },
    {
        "name": "Bar Fight",
        "color": "#073b4c", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/151.png"
    },
    {
        "name": "Pie Fight",
        "color": "#ef476f", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/232.png"
    }
]

We can see that each dictionary item has three properties:

  • name, the name of the item, which corresponds to names specified in the samples definitions above.
  • color, the desired colour of the bars (CSS colour e.g. "#073b4c" or "red").
  • icon, the location of the image to use for the icon.

Visualisation

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!

In [4]:
BarFight(samples,
         nodes=nodes).show()
Plotapi - Bar Fight Diagram

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

Changing the Colours and Icons

Preamble

In [1]:
from plotapi import PieFight

PieFight.set_license("your username", "your license key")

Introduction

Let's take a look at how we can change the colours and icons for nodes in our Pie Fight diagram.

Plotapi Pie Fight is a beautiful and feature rich take on the popular Pie Chart Race. As we can see, we have set our license details in the preamble with PieFight.set_license().

Dataset

Plotapi Pie Fight expects at minimum a list of dictionary items, these will define the value of our segments over time.

In [2]:
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": 38},
    {"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},
]

We can see that each dictionary item has three properties:

  • order, which determines with time period this item belongs to. This should be numerical, but can be formatted e.g. as dates.
  • name, the name of the item, and the text that appears on the pie chart segment.
  • value, the value of the segment at the associated point in time.

Next, we'll start customising the segments, or nodes, that will represent our data over time. Plotapi Pie Fight expects a list of dictionary items to configure each node.

In [3]:
nodes = [
    {
        "name": "Sankey",
        "color": "#ffd166", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/003.png"
    },
    {
        "name": "Terminus",
        "color": "#06d6a0", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/004.png"
    },
    {
        "name": "Chord",
        "color": "#118ab2", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/025.png"
    },
    {
        "name": "Bar Fight",
        "color": "#073b4c", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/151.png"
    },
    {
        "name": "Pie Fight",
        "color": "#ef476f", 
        "icon": "https://datacrayon.com/datasets/pokemon_img/232.png"
    }
]

We can see that each dictionary item has three properties:

  • name, the name of the item, which corresponds to names specified in the samples definitions above.
  • color, the desired colour of the pie chart segment (CSS colour e.g. "#073b4c" or "red").
  • icon, the location of the image to use for the icon.

Visualisation

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!

In [4]:
PieFight(samples,
         nodes=nodes).show()
Plotapi - Pie Fight Diagram

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.