{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Preamble" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from plotapi import HeatMap\n", "import json\n", "\n", "HeatMap.set_license(\"your username\", \"your license key\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction\n", "\n", "In this notebook we're going to use Plotapi Heat Map to visualise the co-occurrences between Pokémon types. We\"ll use Python, but Plotapi can be used from any programming language." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We're going to use Pokémon (Gen 1-8) data, a fork of which is available in this [repository](https://github.com/shahinrostami/pokemon_dataset). Let\"s get loading the data." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "with open(\"pokemon_types.json\", \"r\") as f:\n", " data = json.load(f)\n", " \n", "names = [\"Bug\", \"Dark\", \"Dragon\", \"Electric\", \"Fairy\", \"Fighting\",\n", " \"Fire\", \"Flying\", \"Ghost\", \"Grass\", \"Ground\", \"Ice\",\n", " \"Normal\", \"Poison\", \"Psychic\", \"Rock\", \"Steel\", \"Water\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualisation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's use Plotapi Heat Map for this visualisation, you can see more examples [in the Gallery](https://plotapi.com/gallery/).\n", "\n", "We're going to adjust some layout and template parameters, and flip the intro animation on too.\n", "\n", "Because we're using a data-table, we can also click on any part of the diagram to \"lock\" the selection.
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "Plotapi - Heat Map Diagram\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", "\n", " \n", "\n", "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "HeatMap(\n", " data[\"matrix\"],\n", " col_names=names,\n", " row_names=names,\n", " details_thumbs=data[\"details_thumbs\"],\n", " thumbs_width=50,\n", " thumbs_margin=1,\n", " popup_width=600,\n", " data_table_column_width=100,\n", " data_table=data[\"data_table\"],\n", " data_table_show_indices=False\n", ").show()" ] } ], "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 }