用多种颜色标记 ggdendro 叶子
我遇到一种情况,我正在绘制带有类标签的数据点的树状图。 我希望看到凝聚聚类将具有相同标签的那些聚集在一起。对标签进行颜色编码可以轻松阅读此类树状图。有没有办法用 R 中的 ggdendro 来实现这一点?
I have a situation in which i am plotting a dendrogram with data points that come with class labels.
I wish to see that agglomerative clustering groups those with the same label together. Color coding the labels makes it easy to read such a dendrogram. Is there a way we can achieve this with ggdendro in R ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从这篇文章窃取大部分设置...
...并添加分组因素...
...您可以使用
geom_text()
的aes(colour=)
参数来为标签着色:<图片src="https://i.sstatic.net/4lF7S.png" alt="在此处输入图像描述">
(如果您想提供自己的颜色,可以使用
scale_colour_manual()
,做这样的事情:Stealing most of the setup from this post ...
... and adding a grouping factor ...
... you can use the
aes(colour=)
argument togeom_text()
to color your labels:(If you want to supply your own colors, you can use
scale_colour_manual()
, doing something like this: