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

Changing Pipe Properties


In [2]:
from plotapi import Terminus

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


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().


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.


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.

Made with Plotapi

You can create beautiful, interactive, and engaging visualisations like this one in any programming language with Plotapi.

Get the Books

Enjoying these notebooks and want more on the subject? Check out the practical books on Data Science, Visualisation, and Evolutionary Algorithms.

Get the books