Changing Animation Properties

Preamble

In [2]:
from plotapi import Terminus

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

Introduction

The Terminus animation can be modified to improve the presentation of our diagram, giving us control over a pixel's journey duration, how many pixels are dispatched at once, and the delay before the animation begins.

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.

In [3]:
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

There are many opportunities to customise the Terminus animation.

  • delay, how long to wait before the animation begins
  • pixel_journey_duration, how long each pixel should take from the beginning to end terminus.
  • pixel_batch_size, how many pixels will start their journey at each interval.

Higher pixel_journey_duration and pixel_batch_size values will result in worse performance. We may need to tune them if we want to go to an extreme.

Let's try a fast-moving Terminus diagram.

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!

In [7]:
Terminus(links, delay=3000, pixel_journey_duration=1500, pixel_batch_size=10).show()
Plotapi - Terminus Diagram

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.

Setting the Title including Dynamic Count

Preamble

In [1]:
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.

In [2]:
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!

In [3]:
Terminus(links, title="Watch <plotapi_count> holidaymakers on their journey").show()
Plotapi - Terminus Diagram

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.

Changing Pipe Properties

Preamble

In [2]:
from plotapi import Terminus

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

Introduction

The Terminus pipes can be modified to improve the presentation of our diagram, giving us control over the spacing and slope positions.

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.

In [3]:
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

There are many opportunities to customise the Terminus pipes.

  • slope_start, to change the point at which the pipe starts transitioning from its source $x$ (or $y$) position to its target $x$ (or $y$) position. Whether it's $x$ or $y$ depends on whether it's a vertical Terminus diagram or not. This value must be a float between or equal to $0.0$ and $1.0$.
  • slope_end, similar to the above, but for when the sope ends.
  • target_spacing_ratio, to specify how much of the arrangement should be whitespace versus how much should be taken up by pipe thickness. This value must be a float between or equal to $0.0$ and $1.0$.

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!

In [8]:
Terminus(links, show_stats=False, slope_start=0.1, slope_end=0.9).show()
Plotapi - Terminus Diagram
In [10]:
Terminus(links, show_stats=False, slope_start=0.45, slope_end=0.55).show_png()
In [9]:
Terminus(links, show_stats=False, pipe_spacing_ratio=0.8).show_png()

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.

Changing Stats Properties

Preamble

In [2]:
from plotapi import Terminus

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

Introduction

The stats panel that appears in a default Terminus diagram can be adjusted or hidden entirely. This gives us even more control over the presentation of our 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.

In [3]:
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

There are many opportunities to customise the Terminus stats panel.

  • show_stats, to show or hide the stats panel.
  • stats_text_width, to adjust the width of each stats column.
  • show_stats_title, to hide or show the stats titles.

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!

In [4]:
Terminus(links, show_stats=False).show()
Plotapi - Terminus Diagram
In [5]:
Terminus(links, show_stats_title=False).show_png()
In [6]:
Terminus(links, stats_text_width=150).show_png()

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.

Changing Bar Properties

Preamble

In [ ]:
from plotapi import Terminus

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

Introduction

The bars that appear at each terminus can be modified or hidden entirely. This gives us even more control over the presentation of our 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.

In [ ]:
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

There are many opportunities to customise the Terminus bars.

  • show_bars, to hide or show them.
  • outer_bars, to place the bars inside or outside a terminus.
  • bar_width, to set the maximum width of the bars.
  • colored_target_bars, to enable or disable coloured target bars. By default, they are all black.

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!

In [3]:
Terminus(links, height=400, outer_bars=True, bar_width=150, colored_target_bars=True).show()
Plotapi - Terminus Diagram
In [4]:
Terminus(links, height=400, show_bars=False).show_png()

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.

Changing Pipe Colours

Preamble

In [2]:
from plotapi import Terminus

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

Introduction

The pipe_color and pipe_opacity can be changed to improve the presentation of our 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.

In [3]:
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 pipe_opacity must be a float between or equal to $0.0$ and $1.0$.

The pipe_color must be a colour expressed as a string, e.g. a HEX color code.

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!

In [35]:
Terminus(links, pipe_color="#FFFF00", pipe_opacity=0.1).show()
Plotapi - Terminus Diagram
In [36]:
Terminus(links, pipe_color="#000000", pipe_opacity=1).show_png()
In [40]:
Terminus(links, pipe_color="cyan", pipe_opacity=0.1).show_png()