Related shortcuts on the dendrogram chart - MATLAB

I have the following dataset stored in the stations.dat file:

  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 

Using the following commands,

 Z = linkage (stations.data,'ward','euc'); figure (1), dendrogram(Z,0,'orientation', 'right') 

I get the picture below: enter image description here

Thus, the components of cluster 1 are 4.3.1 (stations D, C, and A, respectively), and cluster 2, 5.2 (stations E and B).

I want to put the name Stations on the chart, but if I use the command:

 set (gca,'YTickLabel', stations.textdata); 

The drawing I get is as follows: enter image description here

How can I associate data with the corresponding names and graph in the dendrogram. I have 144 station data. For illustration, I used only 5.

+4
source share
1 answer

Try the following:

 ind = str2num(get(gca,'YTickLabel')); set(gca, 'YTickLabel',stations.textdata(ind)) 

An easier way is to directly indicate the labels of the data points in the dendrogram call:

 dendrogram(Z,0, 'Orientation','right', 'Labels',stations.textdata) 

dendrogram

+9
source

Source: https://habr.com/ru/post/1483020/


All Articles