Get the Books

Enjoying these notebooks and want to support the work? Check out the practical books on Data Science, Visualisation, and Evolutionary Algorithms.

Get the books

Getting started with Plotapi Pie Fight

Support this work

You can support this work by getting the e-books. This notebook will always be available for free in its online format.

Preamble

In [1]:
from plotapi import PieFight

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

Introduction

Our first Plotapi 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 BarFight.set_license().

Dataset

Plotapi Pie 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 Pie 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]:
PieFight(samples).show()
Plotapi - Pie Fight Diagram

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

Support this work

You can support this work by getting the e-books. This notebook will always be available for free in its online format.

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