Easily turn your data into engaging visualizations. Powerful API for coders. Powerful app for everyone.

main.py
notebook.ipynb
main.rs
from plotapi import Chord

Chord(matrix, names).show()

API for coders

# Pixels per unit

Let's look at a unit-based approach to handling data with very high values or many sources and targets.

For example, if we had a dataset that included values that were in the millions, Terminus may end up trying to process and display a million or more pixels on-screen simultaneously. The result would likely be crashing the tab or browser! Whilst that can be managed with the previously discussed pixel_batch_size and pixel_journey_duration, that approach will likely result in an animation that lasts too long.

Instead, we can start representing more than $1$ “unit” of our value per pixel. For example, we could use one pixel to represent $10$, $100$, or even $1000$ units of our value.

Let’s demonstrate this with a high-value dataset.

## Sample data

Let’s import PlotAPI and load our sample data.

from plotapi import Terminus

{"source":"England", "target":"Germany", "value": 100000},
{"source":"England", "target":"France", "value": 300000},
{"source":"England", "target":"Spain", "value": 500000},
{"source":"England", "target":"Italy", "value": 400000},
{"source":"England", "target":"Japan", "value": 8000},

{"source":"Ireland", "target":"Germany", "value": 350000},
{"source":"Ireland", "target":"France", "value": 375000},
{"source":"Ireland", "target":"Spain", "value": 175000},
{"source":"Ireland", "target":"Italy", "value": 5000},
{"source":"Ireland", "target":"Japan", "value": 40000},
]


## Demonstration

We can see that we’re working with a dataset that contains higher values than usual. Let’s address this by setting pixels_per_unit=100, which means we’ll be representing $100$ units with a single pixel, rather than $100$ units with $100$ pixels. We’ll also need to increase the stats_text_width to make enough space for the bigger numbers.

Terminus(links, stats_text_width=100, colors="warm",
pixels_per_unit=100).show()

Previous
Terminus