3

Setting the Title including Dynamic Count

 2 years ago
source link: https://datacrayon.com/posts/plotapi/terminus/setting-the-title-including-dynamic-count/
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.
neoserver,ios ssh client

Preamble

from plotapi import Terminus

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

Introduction

The Terminus diagram supports setting the title and also including the dynamic count of pixels currently on their journey.

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":"England", "target":"Germany", "value": 1000},
    {"source":"England", "target":"France", "value": 3000},
    {"source":"England", "target":"Spain", "value": 5000},
    {"source":"England", "target":"Italy", "value": 4000},
    {"source":"England", "target":"Japan", "value": 800},

    
    {"source":"Ireland", "target":"Germany", "value": 3500},
    {"source":"Ireland", "target":"France", "value": 3750},
    {"source":"Ireland", "target":"Spain", "value": 1750},
    {"source":"Ireland", "target":"Italy", "value": 5000},
    {"source":"Ireland", "target":"Japan", "value": 400},
]

We can add many source's and target's! As they increase, we may need to adjust Terminus layout properties to accomodate the diagram's size and throughput.

Visualisation

The title can be modified by setting the desired string to the title parameter. Placing the <plotapi_count> tag in that string will create a title whereby that tag is replaced and updated in real-time with the current number of pixels on their journey.

Let's try a few combinations.

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!

Terminus(links, title="Watch <plotapi_count> holidaymakers on their journey").show()

Plotapi - Terminus Diagram

EnglandIrelandGermanyFranceSpainItalyJapan00%00%00%00%00%England00%00%00%00%00%IrelandWatch 640 holidaymakers on their journeyProduced with Plotapi

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK