""" Subtree colorway ================ """ # %% # By default, subtrees are colored using the :attr:`~plotly.graph_objects.Layout.colorway` # attribute of the :attr:`~plotly.graph_objects.Figure.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. fig = go.Figure() attach_dendrogram(fig, Z, subtrees={2, 4}, subtree_colorway=["#ff0000"]) pio.show(fig)