Plotapi, beautiful by default.

Let plotapi do the heavy lifting – enabling beautiful interactive visualisations with a single line of code (instead of hundreds).

Get Plotapi

Getting started with Plotapi Bar Fight

Preamble

In [1]:
from plotapi import BarFight

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

Introduction

Our first Plotapi 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 bars over time.

In [2]:
samples = [
    {"order": 0, "name": "Plotapi Sankey", "value": 10},
    {"order": 0, "name": "Plotapi Terminus", "value": 12},
    {"order": 0, "name": "Plotapi Chord", "value": 14},
    {"order": 0, "name": "Plotapi Bar Fight", "value": 9},
    {"order": 0, "name": "Plotapi Secret", "value": 12},

    {"order": 1, "name": "Plotapi Sankey", "value": 18},
    {"order": 1, "name": "Plotapi Terminus", "value": 24},
    {"order": 1, "name": "Plotapi Chord", "value": 29},
    {"order": 1, "name": "Plotapi Bar Fight", "value": 14},
    {"order": 1, "name": "Plotapi Secret", "value": 17},

    {"order": 2, "name": "Plotapi Sankey", "value": 24},
    {"order": 2, "name": "Plotapi Terminus", "value": 40},
    {"order": 2, "name": "Plotapi Chord", "value": 52},
    {"order": 2, "name": "Plotapi Bar Fight", "value": 19},
    {"order": 2, "name": "Plotapi Secret", "value": 42},

    {"order": 3, "name": "Plotapi Sankey", "value": 32},
    {"order": 3, "name": "Plotapi Terminus", "value": 62},
    {"order": 3, "name": "Plotapi Chord", "value": 72},
    {"order": 3, "name": "Plotapi Bar Fight", "value": 25},
    {"order": 3, "name": "Plotapi Secret", "value": 64},

    {"order": 4, "name": "Plotapi Sankey", "value": 38},
    {"order": 4, "name": "Plotapi Terminus", "value": 75},
    {"order": 4, "name": "Plotapi Chord", "value": 99},
    {"order": 4, "name": "Plotapi Bar Fight", "value": 45},
    {"order": 4, "name": "Plotapi Secret", "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.

Visualisation

Creating our first Bar 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]:
BarFight(samples).show()
Plotapi - Bar Fight Diagram

Here we can see the default behaviour of Plotapi Bar 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.

Made with Plotapi

You can create beautiful, interactive, and engaging visualisations like this one in any programming language with Plotapi.

Get the Books

Enjoying these notebooks and want more on the subject? Check out the practical books on Data Science, Visualisation, and Evolutionary Algorithms.

Get the books