Visualizations Chord
Label styles
Different label styles are more suitable for different chord diagrams, and choosing the right one will improve the look of a PlotAPI Chord diagram.
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
PlotAPI Chord supports multiple label styles:
-
callout
(default) radial
star
Callout labels
With the default setting, label_style="callout"
, we have our labels arranged around our diagram with connecting lines that indicate the corresponding arc.
Chord(matrix, names, label_style="callout").show()
The line colors match those of the segments by default.
This, and the line thickness can be changed with the callout_line_color
and callout_stroke_width
parameters.
Chord(matrix, names,
callout_line_color="black",
callout_stroke_width=2).show()
Radial labels
With the radial setting, label_style="radial"
, we have our labels arranged around our diagram and curved around the corresponding arc.
Chord(matrix, names, label_style="radial").show()
These are not suitable for all datasets - especially those which result in many small arcs.
Star labels
With the radial setting, label_style="star"
, we have our labels arranged around our diagram and aligned outward from the center of the chord diagram.Chord(matrix, names, label_style="radial").show()
Chord(matrix, names, label_style="star").show()