树状图中的关联标签 - MATLAB [英] Associated Labels in a dendrogram plot - MATLAB

查看:40
本文介绍了树状图中的关联标签 - MATLAB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 stations.dat 文件中存储了以下一组数据:

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

通过使用以下命令,

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

我得到下图:

所以集群 1 的组件是 4,3,1(分别是站点 D、C 和 A),集群 2 是 5,2(站点 E 和 B).

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);

我得到的数字如下:

如何将数据关联到各自的名称并在树状图中绘制.我有 144 个电台数据.我只用了 5 个来说明.

How can I associate data to respective names and plot in dendrogram. I have 144 stations data. I used only 5 for illustration.

推荐答案

试试以下:

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

<小时>

更简单的方法是直接在 dendrogram 调用中指定数据点的标签:


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)

这篇关于树状图中的关联标签 - MATLAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆