In the following, these distances are highlighted in red:
Needs["HierarchicalClustering`"]
Grid[{{Agglomerate[{1, 2, 10, 4, 8},
DistanceFunction -> Automatic,
Linkage -> "Single"]},
{DendrogramPlot[{1, 2, 10, 4, 8},
DistanceFunction -> Automatic, Linkage -> "Single",
LeafLabels -> (# &), ImageSize -> 300, Axes -> {False, True},
AxesOrigin -> {0, Automatic}]}}]
Few moreSeveral combinations of DistanceFunction
and Linkage
where inter-cluster distances are highlighted in red and shown as green gridlines in the dendogram plot:
Needs["HierarchicalClustering`"]
Grid[{{ToString@#[[1]] <> "--" <> #[[2]]}, {Replace[
{Replace[ Agglomerate[{1, 2, 10, 4, 8},
DistanceFunction -> #[[1]], Linkage -> #[[2]]],
Cluster[a_, b_, c_, d__] ->
Cluster[a, b, Style[c, 18, Red, Bold], d], {0,
Infinity}]}, {DendrogramPlot[{1, 2, 10, 4, 8},
DistanceFunction -> #[[1]], Linkage -> #[[2]],
LeafLabels -> (# &),
GridLines -> {None, Cases[Agglomerate[{1, 2, 10, 4, 8},
DistanceFunction -> #[[1]], Linkage -> #[[2]]],
Cluster[a_, b_, c_, d__] :> c, {0, Infinity}]},
GridLinesStyle -> Green, ImageSize -> 500,
Axes -> {False, True}, AxesOrigin -> {.75, Automatic}]}}] & /@
Tuples[{{Automatic, ManhattanDistance}, {"Complete", "Centroid"}}] // Column
EDIT: Note: Despite syntax highlightingWhat I get for Frederik's example in red of Axes
and AxesOrigin
, the options seem to workcomments: