Plotapi, beautiful by default.

Let plotapi do the heavy lifting – enabling beautiful interactive visualisations with a single line of code (instead of hundreds).

Get Plotapi

Pokemon Trends Max with Plotapi Bar Fight

Preamble

In [1]:
from plotapi import BarFight
import json

BarFight.set_license("your username", "your license key")

Introduction

In this notebook we're going to use Plotapi Bar Fight to visualise Pokémon search trends over time. We"ll use Python, but Plotapi can be used from any programming language.

The core games are released in generations, each with different Pokémon. We'll include remakes and one popular spin-off - Pokémon Go!

Dataset

We're going to use Pokémon (Gen 1-8) data (a fork of which is available in this repository), combined with data from Google Trends. Let's get loading the data.

The "Interest over time"[1] was retrieved for every Pokemon from Google Trends, for each month between 2004 and 2021. Pikachu was consistently the most popular, so Pikachu was always used as the reference point for every Pokemon. What we're seeing in the plot is the cumulative sum over time.

[1] Interest over time Numbers represent search interest relative to the highest point on the chart for the given region and time. A value of 100 is the peak popularity for the term. A value of 50 means that the term is half as popular. A score of 0 means there was not enough data for this term.

In [2]:
with open("pokemon_trends.json", "r") as f:
    data = json.load(f)
    
samples = data['samples']
nodes = data['nodes']
events = data['events']

icon_base_url = "https://datacrayon.com/images/data-is-beautiful/pokemon_thumbs/"

Visualisation

Let's use Plotapi Bar Fight for this visualisation, you can see more examples in the Gallery.

We're going to adjust some layout and template parameters. These include:

  • event_pause=False: The visualisation won't pause every time an event is displayed.
  • top_n=30: By default, we'll only show 30 bars. We can add/remove bars ourselves by hovering over the visualisation and clicking the + and - buttons.
  • icon_padding=-20: Why a negative number? For this visualisation, as they have transparent backgrounds, I thought it would look nicer to have the Pokemon popping out of their bars.
In [3]:
BarFight(samples, nodes=nodes, events=events, icon_base_url=icon_base_url, event_pause=False,
         width=1000, height=1000, icon_padding=-20, top_n=30, interval=750, 
         background_color="white", border="10px solid black").show()

Made with Plotapi

You can create beautiful, interactive, and engaging visualisations like this one in any programming language with Plotapi.

Get the Books

Enjoying these notebooks and want more on the subject? Check out the practical books on Data Science, Visualisation, and Evolutionary Algorithms.

Get the books