Note
Go to the end to download the full example code.
Subtree colorwayΒΆ
By default, subtrees are colored using the colorway
attribute of the layout attribute of a figure. The color of
an individual subtree is determined automatically. The colorway can be changed using
the subtree_colorway parameter without changing the figure attribute.
import plotly.graph_objects as go
import plotly.io as pio
import scipy
from pdendro import attach_dendrogram
X = [[0.0], [1.0], [3.0], [6.0]]
Z = scipy.cluster.hierarchy.linkage(X)
fig = go.Figure()
attach_dendrogram(fig, Z, subtrees={2, 4}, subtree_colorway=["#ff0000", "#00ff00", "#0000ff"])
pio.show(fig)
If there are fewer colors than subtrees, the same color is used for different subtrees.