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

IMDb Top 1000 with Plotapi Chord

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.

Preamble

In [1]:
from plotapi import Chord
import json

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

Introduction

In this notebook we're going to use Plotapi Chord to visualise the co-occurrences of genres in the IMDb "Top 1000" (Sorted by IMDb Rating Descending). We"ll use Python, but Plotapi can be used from any programming language.

In a chord diagram (or radial network), entities are arranged radially as segments with their relationships visualised by ribbons that connect them. The size of the segments illustrates the numerical proportions, whilst the size of the arc illustrates the significance of the relationships. Chord diagrams are useful when trying to convey relationships between different entities, and they can be beautiful and eye-catching.

Dataset

We're going to use the latest IMDB top 1000 data which is available on their website. Let"s get loading the data.

In [2]:
with open("imdb_top_1000.json", "r") as f:
    data = json.load(f)
    
names = ['Action', 'Adventure', 'Animation', 'Biography', 'Comedy',
         'Crime', 'Drama', 'Family', 'Fantasy', 'Film-Noir',
         'History', 'Horror', 'Music', 'Musical', 'Mystery',
         'Romance', 'Sci-Fi', 'Sport', 'Thriller', 'War', 'Western']

Visualisation

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

We're going to adjust some layout and template parameters, and flip the intro animation on too. We'll also configure the data table to hide the indices, and we'll make sure to compress our data table so we have a smaller output size. Finally, we've also set data_table_unique_column="Name", because we have instances where a title has 3 or more genres, and we don't want them to appear multiple times in the same data table selection.

Because we're using a data-table, we can also click on any part of the diagram to "lock" the selection.

In [4]:
Chord(
    data["matrix"],
    names,
    colors="movies",
    noun="titles",
    data_table_column_width=100,
    data_table_unique_column="Name",
    data_table_show_indices=False,
    compress=True,
    data_table=data["data_table"],
    animated_intro=True
).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