Labeling Dendrogram Plot x-axis

16 views (last 30 days)
Perry
Perry on 1 Feb 2013
Hello,
i worked me trough the example on how to make clusteranalysis
everything works fine except that i cant label my x-axis (hirachical clustering). so i have now the clutered tree but i dont know what 'branch' belongs to my rawdata. so lets say i have a data matrix of 6 colums and 40 rows, and i cant link the actual data to one of the branches because branch one on the plot is not necessarely the first row in my matrix
has anybody an idea how to solve this? thank you in advance
load fisheriris
eucD = pdist(meas,'euclidean');
clustTreeEuc = linkage(eucD,'average');
[h,nodes] = dendrogram(clustTreeEuc,0);
set(gca,'TickDir','out','TickLength',[.002 0],'XTickLabel',[]);

Accepted Answer

Tom Lane
Tom Lane on 1 Feb 2013
You can try this:
> [h,nodes,orig] = dendrogram(clustTreeEuc,0);
>> orig(1:5)
ans =
102 143 114 122 115
These are the first five points (using original row numbers) on the dendrogram. If you zoom into the cluttered plot, you will see the first points are labeled this way. Now unclutter using:
>> set(gca,'XTickMode','auto','XTickLabelMode','auto');
Now the first five points are at positions 1,2,3,4,5. Zoom out. The graph is uncluttered. You can determine the identity of any leaf node by finding its x value (zooming if necessary) and looking up the original row number in the orig vector.

More Answers (1)

Perry
Perry on 4 Feb 2013
great, thank you very much-it worked- do you know if it is possible to do the numbering on x-axis not from 1-5 but rather to use the coresponding row number on every leaf, so for example the x axis starts with 9 because the ninth row of data is on the first position of the graph-just to skip looking at the 'orig' vector file?
  1 Comment
Tom Lane
Tom Lane on 4 Feb 2013
When I try this, the dendrogram is already that way before the "set" command. If I zoom in I see numbering starting from the left with 102, 143, 114, etc. corresponding to original data row numbers.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!