Visualizations Chord
Highlighted arcs
PlotAPI Chord supports highlighting arcs and chords by default as a way to highlight or group elements.
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
highlighting arcs can be controlled with the highlight parameter. It expects a list of binary values, one for each arc, indicating how far out to pull.
Let's highlight the Adventure arc. It's the second item in our names list above, so we'll adjust the second position.
Highlighting is best paired with our opacity parameters:
opacityopacity_highlightedopacity_unhighlighted
Chord(matrix, names,
opacity=0.2,
opacity_highlighted=1,
opacity_unhighlighted=0.1,
highlight=[0, 1, 0, 0, 0, 0]).show()
Let's highlight Drama, and pull it out too.
Chord(matrix, names,
opacity=0.2,
opacity_highlighted=1,
opacity_unhighlighted=0.1,
highlight=[0, 1, 0, 1, 0, 0],
pull=[0, 0, 0, 30, 0, 0]).show()
Highlighting groups
Let's highlight Thriller and Action as if they are somehow related.
Chord(
matrix,
names,
colors=["red", "blue", "blue", "blue", "blue", "red"],
opacity=0.2,
opacity_highlighted=1,
opacity_unhighlighted=0.1,
highlight=[1, 0, 0, 0, 0, 1],
pull=[20, 0, 0, 0, 0, 20],
).show()