Get the Books

Enjoying these notebooks and want to support the work? Check out the practical books on Data Science, Visualisation, and Evolutionary Algorithms.

Get the books

Pokemon Trends Max with Plotapi Bar Fight

Support this work

You can support this work by getting the e-books. This notebook will always be available for free in its online format.


In [1]:
from plotapi import BarFight
import json

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


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!


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 = ""


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()

Support this work

You can support this work by getting the e-books. This notebook will always be available for free in its online format.

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