Statistics Toolbox | ![]() ![]() |
Syntax
H = dendrogram(Z)
H = dendrogram(Z,p)
[H,T] = dendrogram(...)
[H,T,perm] = dendrogram(...)
[...] = dendrogram(...,'colorthreshold',t)
[...] = dendrogram(...,'orientation','orient
')
Description
generates a dendrogram plot of the hierarchical, binary cluster tree, H = dendrogram(Z)
Z
. Z
is an (m
-1)-by-3 matrix, generated by the linkage
function, where m
is the number of objects in the original dataset.
A dendrogram consists of many U-shaped lines connecting objects in a hierarchical tree. Except for the Ward linkage (see linkage
), the height of each U represents the distance between the two objects being connected. The output, H
, is a vector of line handles.
generates a dendrogram with only the top H = dendrogram(Z,p)
p
nodes. By default, dendrogram
uses 30 as the value of p
. When there are more than 30 initial nodes, a dendrogram may look crowded. To display every node, set p = 0
.
[H,T] = dendrogram(...)
generates a dendrogram and returns T
, a vector of length m
that contains the leaf node number for each object in the original dataset. T
is useful when p
is less than the total number of objects, so some leaf nodes in the display correspond to multiple objects. For example, to find out which objects are contained in leaf node k
of the dendrogram, use find(T==k)
. When there are fewer than p
objects in the original data, all objects are displayed in the dendrogram. In this case, T
is the identity map, i.e., T = (1:m)'
, where each node contains only itself.
When there are fewer than p
objects in the original data, all objects are displayed in the dendrogram. In this case, T
is the identity map, i.e., T = (1:m)'
, where each node contains only itself.
[H,T,perm] = dendrogram(...)
generates a dendrogram and returns the permutation vector of the node labels of the leaves of the dendrogram. perm
is ordered from left to right on a horizontal dendrogram and bottom to top for a vertical dendrogram.
[...] = dendrogram(...,'colorthreshold',t)
assigns a unique color to each group of nodes in the dendrogram where the linkage is less than the threshold t
. t
is a value in the interval [0,max(Z(:,3))]
. Setting t
to the string 'default'
is the same as t = .7(max(Z(:,3)))
. 0
is the same as not specifying 'colorthreshold'
. The value max(Z(:,3))
treats the entire tree as one group and colors it all one color.
[...] = dendrogram(...,'orientation','
orients the dendrogram within the figure window. The options for 'orient
')
orient
' are
'top' |
Top to bottom (default) |
'bottom' |
Bottom to top |
'left' |
Left to right |
'right' |
Right to left |
Example
rand('seed',12); X= rand(100,2); Y= pdist(X,'cityblock'); Z= linkage(Y,'average'); [H,T] = dendrogram(Z,'colorthreshold','default'); find(T==20) ans = 20 49 62 65 73 96
This output indicates that leaf node 20 in the dendrogram contains the original data points 20, 49, 62, 65, 73, and 96.
See Also
cluster
, clusterdata
, cophenet
, inconsistent
, linkage
, pdist
, silhouette
, squareform
![]() | dcovary | disttool | ![]() |