1

1.) This is the code for polar dendrogram:

X= rand(100,2);
Y= pdist(X,'cityblock');
Z= linkage(Y,'average');
dendrogram(Z,'colorthreshold','default');

But I want to do the labelling of my text.data file as shown in this question. I don't want numbering labels and want the text from my string file


Can we do the same labelling in case of polardendrogram

polardendrogram(Z,0,'colorthreshold','default');
zoom(0.8);
view(2);

if we have large data sets for rows labels ?

Sam Roberts
  • 23,951
  • 1
  • 40
  • 64

1 Answers1

0

I think you're probably using the polardendrogram command from here, correct?

If so, sweet! I wrote that about twelve years ago - nice to see that someone's using it!

So if you want to see the labels, you should probably do this.

  1. Open the file polardendrogram.m
  2. Go to the section %Relabel leaves, it starts at line 45.
  3. Modify it so that it says the following:

%Relabel leaves
labels = get(gca, 'XTickLabel');
for i=minx+1:maxx-1
    [x,y]=pol2cart((((i-minx)/xrange)*(pi*11/6))+(pi*1/12),1.1);
    text(x,y,labels{i});
%     text(x,y,num2str(perm(i)));
end

This code will add the specified labels in, rather than always putting the row numbers.


  1. Now you can call it as follows:

for i = 1:100
    labels{i} = ['label', num2str(i)];
end
X= rand(100,2);
Y= pdist(X,'cityblock');
Z= linkage(Y,'average');
numNodesToDisplay = size(X,1);
polardendrogram(Z, numNodesToDisplay, 'colorthreshold','default', 'Labels', labels);

Good luck!

Sam Roberts
  • 23,951
  • 1
  • 40
  • 64
  • Sir, I'm not getting it. I tried it but it is giving numbers for labels. Please give me one example if possible for data and label file if possible. I will be highly obliged to you. – sumit mishra Sep 26 '18 at 14:17
  • @sumitmishra See my edit (`numNodesToDisplay`). I'm guessing you have a large number of nodes to display. If that's the case, then by default MATLAB will collapse some of the nodes (by default it displays only 30). The collapsed nodes will always display numbers, it doesn't matter if you supplied labels. So you can specify the full number of nodes, and I think this should give you what you need. – Sam Roberts Sep 26 '18 at 15:38