I have the following set of data stored in file stations.dat
:
Station A 305.2 321.1 420.9 383.5 311.7 197.1 160.2 113.9 60.5 60.5 64.8 154.3
Station B 281.1 304.0 353.1 231.9 84.6 20.9 11.7 11.9 31.1 75.8 133.0 235.3
Station C 312.3 342.2 366.2 335.2 200.1 74.4 45.9 27.5 24.0 53.6 87.7 177.0
Station D 402.2 524.5 554.9 529.5 347.5 176.8 120.2 35.0 12.6 13.3 14.0 61.6
Station E 261.3 262.7 282.3 232.6 103.8 33.2 16.7 33.2 111.0 149.0 184.8 227.0
By using the following commands,
Z = linkage (stations.data,'ward','euc');
figure (1), dendrogram(Z,0,'orientation', 'right')
I get the figure below:
So cluster 1 components are 4,3,1 (Stations D,C and A, respectively) and cluster 2 are 5,2(Stations E and B).
I want to put the name of Stations on plot, but if I use the command:
set (gca,'YTickLabel', stations.textdata);
The figure I get is the following:
How can I associate data to respective names and plot in dendrogram. I have 144 stations data. I used only 5 for illustration.
Try the following:
ind = str2num(get(gca,'YTickLabel'));
set(gca, 'YTickLabel',stations.textdata(ind))
An easier way would be to specify the labels of the data points in the dendrogram
call directly:
dendrogram(Z,0, 'Orientation','right', 'Labels',stations.textdata)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With