Getting started with Plotapi Terminus
source link: https://datacrayon.com/posts/plotapi/terminus/getting-started-with-terminus/
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 Terminus Terminus.set_license("your username", "your license key")
Introduction¶
Your first Plotapi Terminus Diagram! As we can see, we have set our license details in the preamble with Terminus.set_license()
.
Dataset¶
Terminus expects a list
of dictionary
items, these will define the flow of pixels between a source
and a target
.
links = [ {"source":"Group A", "target":"First Class", "value": 1000}, {"source":"Group A", "target":"Second Class (Upper)", "value": 4000}, {"source":"Group A", "target":"Second Class (Lower)", "value": 5000}, {"source":"Group A", "target":"Third Class", "value": 1000}, {"source":"Group A", "target":"Withdrawn", "value": 300}, {"source":"Group B", "target":"First Class", "value": 500}, {"source":"Group B", "target":"Second Class (Upper)", "value": 1000}, {"source":"Group B", "target":"Second Class (Lower)", "value": 2000}, {"source":"Group B", "target":"Third Class", "value": 5500}, {"source":"Group B", "target":"Withdrawn", "value": 1300} ]
We can add many source
's and target
's, whilst ensuring every source
has a link entry for every target
(even if the value
is 0).
Visualisation¶
Creating our first Terminus 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 a HTML file with .to_html()
instead. More on the different output methods later!
Terminus(links).show()
Plotapi - Terminus 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.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK