Labeling Dendrogram Plot x-axis

조회 수: 4 (최근 30일)
Perry
Perry 2013년 2월 1일
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',[]);

채택된 답변

Tom Lane
Tom Lane 2013년 2월 1일
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.

추가 답변 (1개)

Perry
Perry 2013년 2월 4일
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
Tom Lane
Tom Lane 2013년 2월 4일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by