Note
Go to the end to download the full example code.
Showing all node markersΒΆ
By default, node markers are visible only for root nodes of subtrees. Visibility is controlled by marker sizes. All node markers can be shown by resetting marker sizes to the default.
import plotly.graph_objects as go
import plotly.io as pio
import scipy
from pdendro import make_components
X = [[0.0], [1.0], [3.0], [6.0]]
Z = scipy.cluster.hierarchy.linkage(X)
T = scipy.cluster.hierarchy.fcluster(Z, 1.5, criterion="distance")
L, _ = scipy.cluster.hierarchy.leaders(Z, T)
node_trace, link_traces, x_axis, y_axis = make_components(Z, subtrees=L)
node_trace.update(marker={"size": None})
fig = go.Figure()
fig.add_traces(list(link_traces.values()))
fig.add_trace(node_trace)
fig.update_xaxes(x_axis)
fig.update_yaxes(y_axis)
pio.show(fig)
Alternatively, if the attach_dendrogram() function is used, marker sizes must be
modified later.
from pdendro import attach_dendrogram
fig = go.Figure()
attach_dendrogram(fig, Z, subtrees=L)
node_trace = fig.data[-1]
node_trace.update(marker={"size": None})
pio.show(fig)