Represent a radial dendrogram in MATLAB
I want to represent the dendrogram in radial lines with arcs.
So far I have tried
t2=linkage(squareform(t1),'single')
dendrogram(t2,0,'colorthreshold',0.5)
and got the result as
Could you please let me know how to represent the same as a radial dendrogram in MATLAB like in the image below.
source to share
You can try my Polar Dendrogram function from MATLAB Central: http://www.mathworks.co.uk/matlabcentral/fileexchange/21983-draw-a-polar-dendrogram
Hope it works for you!
source to share
Matlab does not have a built-in function to create a radial dendrogram. A quick search showed a page about hierarchical random graphs with code that might work for you.
source to share
I modified the Matlab code provided by @Sam Roberts and attached a diff to the files:
1c1
< function [h,T,perm] = polardendrogram(Z,varargin)
---
> function [h,T,perm] = polardendrogram(Z, labels, varargin)
47,48c47,49
< [x,y]=pol2cart((((i-minx)/xrange)*(pi*11/6))+(pi*1/12),1.1);
< text(x,y,num2str(perm(i)));
---
> [x,y]=pol2cart((((i-minx)/xrange)*(pi*11/6))+(pi*1/12),1.01);
> THETA = (((i-minx)/xrange)*330 + 15); % pi/12 = 15°
> text(x,y,labels(perm(i)), 'rotation', THETA);
As you can see, this requires you to provide labels before the arguments, which you would normally pass to Matlab's built-in dendrogram () function, which polardendrogram () is based on.
There is probably a cleaner way to do it, but this one works for me.
If you have any comments on this, please let me know.
source to share