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

Customising the Nodes

Preamble

In [1]:
from plotapi import Sankey

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

Introduction

The nodes in a Plotapi Sankey diagram can be customised with many different parameters.

As we can see, we have set our license details in the preamble with Sankey.set_license().

Dataset

Plotapi Sankey expects a list of dictionary items, these will define the flow between a source and a target.

In [2]:
links = [
    {"source":"Group A", "target":"Rank 1", "value": 1000},
    {"source":"Group B", "target":"Rank 1", "value": 300},
    {"source":"Group B", "target":"Rank 2", "value": 600},
    {"source":"Group B", "target":"Rank 3", "value": 400},
    {"source":"Rank 1", "target":"Club A", "value": 700},
    {"source":"Rank 1", "target":"Club B", "value": 400},
    {"source":"Rank 1", "target":"Club C", "value": 200},
    {"source":"Rank 2", "target":"Club B", "value": 200},
    {"source":"Rank 2", "target":"Club C", "value": 400},
    {"source":"Rank 3", "target":"Withdrawn", "value": 400},
    {"source":"Club A", "target":"The Most Amazing Prize", "value": 500},
]

We can add many source's and target's in any arrangement.

Visualisation

The nodes can be customised with the following parameters:

  • node_width - the thickness of the node.
  • node_padding - the padding between each node.
  • node_opacity - the opacity of the node colour.
  • node_darken_factory - how much darker the node colour appears (between and including $0$ and $1$).
  • node_border_width - the thickness of the node border.
  • node_border_color- the colour of the node border.
  • node_font_size - the node label font size.

Let's demonstrate these below.

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 settings can do!

In [3]:
Sankey(links, link_numbers=False, 
       node_width=40, node_padding=40, node_opacity=0.75,
       node_darken_factor=1, node_border_width=10,
       node_border_color="#f8f8f8", node_font_size=18).show()
Plotapi - Sankey 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.

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