matlab - 树状图中的关联标签 - MATLAB

标签 matlab plot label cluster-analysis dendrogram

我在文件 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')

我得到下图: enter image description here

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

我想把 Stations 的名字放在 plot 上,但是如果我使用命令:

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

我得到的图如下: enter image description here

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

最佳答案

尝试以下操作:

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

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

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

dendrogram

关于matlab - 树状图中的关联标签 - MATLAB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16779256/

相关文章:

matlab - 高斯消元法不起作用

matlab - 从视频重建 3D 轨迹(由单个相机拍摄)

matlab - 计算方阵的部分累积和

R Shiny 改变情节高度

r - data.frames 上 R Hmisc 包列 "labels"的替代方案

r - 是否有一种巧妙的方法可以使用来自 geom_quantile() 的方程和其他统计数据来标记 ggplot 图?

matlab - 将标志传递给 Matlab 函数的最巧妙方法是什么?

python - 给3分和一个情节圈

r - "Error in int_abline...plot.new has not been called yet"

python - Matplotlib - 在具有值 z 的线上标记点 (x,y)