Engaging plots, made easy.

Easily turn your data into engaging visualizations. Powerful API for coders. Powerful app for everyone.

main.py
notebook.ipynb
main.rs
from plotapi import Chord

Chord(matrix, names).show()

Visualizations Chord

Chord colors

The color scheme can be set to one of many beautiful presets, or even a customized by supplying a list of colors (HEX, RGB, etc.).


Sample data

Let's import PlotAPI and load our sample data.

from plotapi import Chord

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

Demonstration

To specify chord colors, we can set the colors parameter to one of the following:

  • A list of color strings, e.g. ["#264653","#2a9d8f","#e9c46a","#f4a261","#e76f51"]. If there are fewer colors than there are categories, PlotAPI Chord will loop round the colors.
  • The name of a color scheme from one of the many beautuful presets.

The default color scheme is "rainbow". Let's try a few different color schemes.

Chord(matrix, names, colors="cool").show()
Chord(matrix, names, colors="red_yellow_blue").show_png()
Notebook PNG image
Chord(matrix, names, colors=["#B8D0EB", "cyan", "rgb(111,45,189)"]).show_png()
Notebook PNG image

Color presets

Take advantage of one of our color presets by passing in its name to the color parameter. Choose from one of the following:

['monsters', 'league', 'movies', 'category10', 'accent', 'dark2', 'paired', 'pastel1', 'pastel2', 'set1', 'set2', 'set3', 'tableau10', 'rainbow', 'sinebow', 'yellow_red', 'yellow_brown', 'yellow_green', 'yellow_blue', 'red_purple', 'purple_red', 'purple_blue', 'orange_red', 'green_blue', 'blue_purple', 'blue_green', 'cubehelix', 'cool', 'warm', 'cividis', 'plasma', 'magma', 'inferno', 'viridis', 'turbo', 'brown_green', 'purple_green', 'pink_green', 'red_blue', 'red_grey', 'red_yellow_blue', 'red_yellow_green', 'spectral', 'blues', 'greens', 'greys', 'oranges', 'purples', 'reds']

Flat colors

Visualizations may benefit from flat colors rather the default gradients. Gradient colors can be disabled with gradient_colors=False. This is particularly useful for directed Chord idagrmas.

Chord(matrix, names,
      gradient_colors=False).show()
PlotAPI - Chord Diagram

Stroke color and width

The stroke color and width can be adjusted for chords and arcs in the diagram. This also pairs nicely with gradient_colors=False.

Chord(matrix, names,
      gradient_colors=False,
      chord_stroke_color="black",
      arc_stroke_color="black",
      chord_stroke_width=1,
      arc_stroke_width=1).show()
PlotAPI - Chord Diagram
Previous
Chord