{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Preamble" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from plotapi import Terminus\n", "\n", "Terminus.set_license(\"your username\", \"your license key\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction\n", "\n", "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.\n", "\n", "As we can see, we have set our license details in the preamble with `Terminus.set_license()`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Terminus expects a `list` of `dictionary` items, these will define the flow of pixels between a `source` and a `target`." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "links = [\n", " {\"source\":\"England\", \"target\":\"Germany\", \"value\": 1000},\n", " {\"source\":\"England\", \"target\":\"France\", \"value\": 3000},\n", " {\"source\":\"England\", \"target\":\"Spain\", \"value\": 5000},\n", " {\"source\":\"England\", \"target\":\"Italy\", \"value\": 4000},\n", " {\"source\":\"England\", \"target\":\"Japan\", \"value\": 800},\n", "\n", " \n", " {\"source\":\"Ireland\", \"target\":\"Germany\", \"value\": 3500},\n", " {\"source\":\"Ireland\", \"target\":\"France\", \"value\": 3750},\n", " {\"source\":\"Ireland\", \"target\":\"Spain\", \"value\": 1750},\n", " {\"source\":\"Ireland\", \"target\":\"Italy\", \"value\": 5000},\n", " {\"source\":\"Ireland\", \"target\":\"Japan\", \"value\": 400},\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualisation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are many opportunities to customise the Terminus animation.\n", "\n", "- `delay`, how long to wait before the animation begins\n", "- `pixel_journey_duration`, how long each pixel should take from the beginning to end terminus.\n", "- `pixel_batch_size`, how many pixels will start their journey at each interval.\n", "\n", "**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.\n", "\n", "Let's try a fast-moving Terminus diagram.\n", "\n", "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!
" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", " \n", " \n", " Plotapi - Terminus Diagram\n", " \n", " \n", " \n", "\n", " \n", "
\n", " \n", " \n", "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Terminus(links, delay=3000, pixel_journey_duration=1500, pixel_batch_size=10).show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.1" } }, "nbformat": 4, "nbformat_minor": 4 }