dendrogram - Dendrogram plot

Syntax

H = dendrogram(Z)
H = dendrogram(Z,p)
[H,T] = dendrogram(...)
[H,T,perm] = dendrogram(...)
[...] = dendrogram(...,'colorthreshold',t)
[...] = dendrogram(...,'orientation','orient')
[...] = dendrogram(...,'labels',S)

Description

H = dendrogram(Z) generates a dendrogram plot of the hierarchical, binary cluster tree represented by Z. Z is an (m-1)-by-3 matrix, generated by the linkage function, where m s the number of objects in the original data set. The output, H, is a vector of handles to the lines in the dendrogram.

A dendrogram consists of many U-shaped lines connecting objects in a hierarchical tree. The height of each U represents the distance between the two objects being connected. If there were 30 or fewer data points in the original dataset, each leaf in the dendrogram corresponds to one data point. If there were more than 30 data points, the complete tree can look crowded, and dendrogram collapses lower branches as necessary, so that some leaves in the plot correspond to more than one data point.

H = dendrogram(Z,p) generates a dendrogram with no more than p leaf nodes, by collapsing lower branches of the tree. To display the complete tree, 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 data set. 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 a single object.

[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','orient') orients the dendrogram within the figure window. The options for 'orient' are

'top'

Top to bottom (default)

'bottom'

Bottom to top

'left'

Left to right

'right'

Right to left

[...] = dendrogram(...,'labels',S) accepts a character array or cell array of strings S with one label for each observation. Any leaves in the tree containing a single observation are labeled with that observation's label.

Example

X = rand(100,2);
Y = pdist(X,'cityblock');
Z = linkage(Y,'average');
[H,T] = dendrogram(Z,'colorthreshold','default');
set(H,'LineWidth',2)

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, silhouette

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS