{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Preamble" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from plotapi import BarFight\n", "\n", "BarFight.set_license(\"your username\", \"your license key\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction\n", "\n", "Our first Plotapi Bar Fight Diagram! \n", "\n", "Plotapi Bar Fight is a beautiful and feature rich take on the popular Bar Chart Race. As we can see, we have set our license details in the preamble with `BarFight.set_license()`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plotapi Bar Fight expects at minimum a `list` of `dictionary` items, these will define the value of our bars over time." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "samples = [\n", " {\"order\": 0, \"name\": \"Plotapi Sankey\", \"value\": 10},\n", " {\"order\": 0, \"name\": \"Plotapi Terminus\", \"value\": 12},\n", " {\"order\": 0, \"name\": \"Plotapi Chord\", \"value\": 14},\n", " {\"order\": 0, \"name\": \"Plotapi Bar Fight\", \"value\": 9},\n", " {\"order\": 0, \"name\": \"Plotapi Secret\", \"value\": 12},\n", "\n", " {\"order\": 1, \"name\": \"Plotapi Sankey\", \"value\": 18},\n", " {\"order\": 1, \"name\": \"Plotapi Terminus\", \"value\": 24},\n", " {\"order\": 1, \"name\": \"Plotapi Chord\", \"value\": 29},\n", " {\"order\": 1, \"name\": \"Plotapi Bar Fight\", \"value\": 14},\n", " {\"order\": 1, \"name\": \"Plotapi Secret\", \"value\": 17},\n", "\n", " {\"order\": 2, \"name\": \"Plotapi Sankey\", \"value\": 24},\n", " {\"order\": 2, \"name\": \"Plotapi Terminus\", \"value\": 40},\n", " {\"order\": 2, \"name\": \"Plotapi Chord\", \"value\": 52},\n", " {\"order\": 2, \"name\": \"Plotapi Bar Fight\", \"value\": 19},\n", " {\"order\": 2, \"name\": \"Plotapi Secret\", \"value\": 42},\n", "\n", " {\"order\": 3, \"name\": \"Plotapi Sankey\", \"value\": 32},\n", " {\"order\": 3, \"name\": \"Plotapi Terminus\", \"value\": 62},\n", " {\"order\": 3, \"name\": \"Plotapi Chord\", \"value\": 72},\n", " {\"order\": 3, \"name\": \"Plotapi Bar Fight\", \"value\": 25},\n", " {\"order\": 3, \"name\": \"Plotapi Secret\", \"value\": 64},\n", "\n", " {\"order\": 4, \"name\": \"Plotapi Sankey\", \"value\": 38},\n", " {\"order\": 4, \"name\": \"Plotapi Terminus\", \"value\": 75},\n", " {\"order\": 4, \"name\": \"Plotapi Chord\", \"value\": 99},\n", " {\"order\": 4, \"name\": \"Plotapi Bar Fight\", \"value\": 45},\n", " {\"order\": 4, \"name\": \"Plotapi Secret\", \"value\": 120},\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can see that each dictionary item has three properties:\n", "- `order` which determines with _time period_ this item belongs to. This should be numerical, but can be formatted e.g. as dates.\n", "- `name` the name of the item, and the text that appears on the bar.\n", "- `value` the value of the bar at the associated point in time." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualisation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Creating our first Bar Fight Diagram is as easy as calling Plotapi with our one input.\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!\n", "\n", "Be sure to interact with the visualisation to see what the default settings can do!\n", "
" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", " \n", " Plotapi - Bar Fight Diagram\n", "\n", " \n", "\n", " \n", "\n", "\n", "\n", "
\n", " \n", "\n", "\n", "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "BarFight(samples).show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we can see the default behaviour of Plotapi Bar Fight.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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 }