Visualizations Chord
Directed chords
The default behaviour of PlotAPI chord is to represent both sides of a relationship with a single chord. However, it may be more suitable to use two different chords with arrows to indicate the dimension of a relationship.
Sample data
Let's import PlotAPI and load our sample data.
from plotapi import Chord
matrix = [
[0, 5, 6, 4],
[2, 0, 5, 4],
[6, 5, 0, 4],
[2, 4, 3, 0],
]
names = ["Action", "Adventure", "Comedy", "Drama"]
Demonstration
To enable directed mode, we only need to set the directed
parameter to true
.
Chord(matrix, names, directed=True, colors="spectral").show()
The directed Chord diagram can be paired with reverse_gradients=True
to make it easier to see where inbound/outbound relationships are coming from or going to.
Chord(matrix, names, directed=True, colors="spectral", reverse_gradients=True).show()
Directed chord diagrams often are easier to navigate when disabling gradient colors and setting the stroke.
Chord(matrix, names,
directed=True,
colors="spectral",
gradient_colors=False,
chord_stroke_color="black",
arc_stroke_color="black",
chord_stroke_width=1,
arc_stroke_width=1).show()