10

Getting started with Plotapi Chord

 3 years ago
source link: https://datacrayon.com/posts/plotapi/chord/getting-started-with-chord/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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
covertops.jpg

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 - Chord Diagram

ActionAdventureComedyDramaFantasyThrillerProduced with Plotapi

Preamble

from plotapi import Chord

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

Introduction

Your first Plotapi Chord Diagram! As we can see, we have set our license details in the preamble with Chord.set_license()

Dataset

Chord expects a list of names (list[str]) and a co-occurence matrix (list[list[float]]) as input.

matrix = [
    [0, 5, 6, 4, 7, 4],
    [5, 0, 5, 4, 6, 5],
    [6, 5, 0, 4, 5, 5],
    [4, 4, 4, 0, 5, 5],
    [7, 6, 5, 5, 0, 4],
    [4, 5, 5, 5, 4, 0],
]

names = ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]

It may look more clear if we present this as a table with the columns and indices labelled.

import pandas as pd
pd.DataFrame(matrix, columns=names, index=names)

Action Adventure Comedy Drama Fantasy Thriller Action 0 5 6 4 7 4 Adventure 5 0 5 4 6 5 Comedy 6 5 0 4 5 5 Drama 4 4 4 0 5 5 Fantasy 7 6 5 5 0 4 Thriller 4 5 5 5 4 0

Visualisation

Creating our first Chord Diagram is as easy as calling Plotapi with our two inputs.

Here we're using .show() which outputs to a Jupyter Notebook cell, however, we may want to output to a HTML file with .to_html() instead. More on the different output methods later!

Be sure to interact with the visualisation to see what the default settings can do!

Chord(matrix, names).show()

Plotapi - Chord Diagram

ActionAdventureComedyDramaFantasyThrillerProduced with Plotapi

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.

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.

Support this work

Get the practical book on data visualisation that shows you how to create static and interactive visualisations that are engaging and beautiful.

  • Discounted Price that will grow as the book does,
  • Code examples primarily in Python,
  • Python Notebooks for each Section,
  • Format: PDF download,
  • Supplementary Video Tutorials,
  • Unlimited access to updates.

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
covertops.jpg

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK