![](/style/images/good.png)
![](/style/images/bad.png)
Getting started with Plotapi Pie Fight
source link: https://datacrayon.com/posts/plotapi/piefight/getting-started-with-piefight/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Preamble¶
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.
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!
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.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK