{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Preamble" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from plotapi import ParetoFront\n", "\n", "ParetoFront.set_license(\"your username\", \"your license key\")" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "# Introduction\n", "\n", "Our first Plotapi Pareto Front Diagram! \n", "\n", "Plotapi Pareto Front is a beautiful and feature rich take on non-dominated sorting over time. As we can see, we have set our license details in the preamble with `ParetoFront.set_license()`." ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "# Dataset" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "Plotapi Pareto Front expects at minimum a `list` of `dictionary` items, these will define bi-objective solutions over time." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "tags": [] }, "outputs": [], "source": [ "samples = [\n", " {'order': 20200101, 'objv_1': 40, 'objv_2': 12}, \n", " {'order': 20200101, 'objv_1': 40, 'objv_2': 12}, \n", " {'order': 20200101, 'objv_1': 40, 'objv_2': 12}, \n", "\n", " {'order': 20200104, 'objv_1': 40, 'objv_2': 12}, \n", " {'order': 20200104, 'objv_1': 40, 'objv_2': 12}, \n", " {'order': 20200104, 'objv_1': 40, 'objv_2': 14}, \n", "\n", " {'order': 20200109, 'objv_1': 40, 'objv_2': 12}, \n", " {'order': 20200109, 'objv_1': 45, 'objv_2': 12}, \n", " {'order': 20200109, 'objv_1': 45, 'objv_2': 10}, \n", "\n", " {'order': 20200112, 'objv_1': 50, 'objv_2': 12}, \n", " {'order': 20200112, 'objv_1': 50, 'objv_2': 11}, \n", " {'order': 20200112, 'objv_1': 50, 'objv_2': 10}, \n", "\n", " {'order': 20200115, 'objv_1': 50, 'objv_2': 12}, \n", " {'order': 20200115, 'objv_1': 50, 'objv_2': 12}, \n", " {'order': 20200115, 'objv_1': 50, 'objv_2': 12}, \n", "\n", " {'order': 20200115, 'objv_1': 50, 'objv_2': 12}, \n", " {'order': 20200115, 'objv_1': 50, 'objv_2': 12}, \n", " {'order': 20200115, 'objv_1': 50, 'objv_2': 12}, \n", "\n", " {'order': 20200120, 'objv_1': 60, 'objv_2': 8}, \n", " {'order': 20200120, 'objv_1': 60, 'objv_2': 8}, \n", " {'order': 20200120, 'objv_1': 60, 'objv_2': 8}, \n", "\n", " {'order': 20200123, 'objv_1': 60, 'objv_2': 8}, \n", " {'order': 20200123, 'objv_1': 60, 'objv_2': 8}, \n", " {'order': 20200123, 'objv_1': 60, 'objv_2': 8}, \n", " {'order': 20200123, 'objv_1': 80, 'objv_2': 3}, \n", " {'order': 20200123, 'objv_1': 30, 'objv_2': 20}, \n", "\n", " {'order': 20200125, 'objv_1': 30, 'objv_2': 20}, \n", " {'order': 20200125, 'objv_1': 10, 'objv_2': 20}, \n", "\n", " {'order': 20200129, 'objv_1': 120, 'objv_2': 50}, \n", " {'order': 20200129, 'objv_1': 50, 'objv_2': 120}, \n", " {'order': 20200129, 'objv_1': 50, 'objv_2': 120}, \n", " {'order': 20200129, 'objv_1': 50, 'objv_2': 120}, \n", "\n", " {'order': 20200130, 'objv_1': 100, 'objv_2': 100}, \n", "]" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "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", "- `objv_1` the first objective value, e.g. \"weight\".\n", "- `objv_2` the second objective value, e.g. \"reps\".\n", "\n", "\n", "We can also populate the `events` structure to present event text at specific times." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "tags": [] }, "outputs": [], "source": [ "events = [\n", " {\n", " \"order\": 20200101,\n", " \"event\": \"My first ever gym visit!\"\n", " },\n", " {\n", " \"order\": 20200109,\n", " \"event\": \"I went a little heavier today!\"\n", " },\n", " {\n", " \"order\": 20200120,\n", " \"event\": \"Three solid sets of 60 kg!\"\n", " },\n", " {\n", " \"order\": 20200129,\n", " \"event\": \"Broke some records today!\"\n", " }\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualisation" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "Creating our first Pareto Front 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": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "PlotAPI - ParetoFront Diagram\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", "\n", " \n", "\n", "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ParetoFront(samples, events=events, title=\"Bench Press\",\n", " objv_1_unit=\" kg\", objv_2_unit=\" reps\",\n", " x_label=\"Weight(kg)\", y_label=\"Reps\").show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we can see the default behaviour of Plotapi Pareto Front.\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.10.4" } }, "nbformat": 4, "nbformat_minor": 4 }