from plotapi import Chord import json Chord.set_license("your username", "your license key")
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.
We're going to use the latest IMDB top 1000 data which is available on their website. Let"s get loading the data.
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']
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.
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()