ggtree:如何以最简单的方式标记树枝

发布于 2025-01-14 16:38:44 字数 262 浏览 5 评论 0原文

我想在树上标记特定分支(例如“组 1”),但我没有找到执行此操作的特定函数。有什么想法吗?

set.seed(123)
tree <- rtree(30)
plot(tree)

输入图片此处描述

I want to label a specific branch (e.g., "Group 1") on the tree, but I didn't found a specific function to do that. Any ideas?

set.seed(123)
tree <- rtree(30)
plot(tree)

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池予 2025-01-21 16:38:45

您实际上并没有使用 ggtree 来绘制此处。如果你想用 ggtree 来绘制树,你可以这样做:

library(ggtree)
library(ggplot2)

set.seed(123)
tree <- rtree(30)

ggplot(tree) + 
  geom_tree() +
  geom_tiplab() +
  geom_text(aes(0.5, 20), label = 'Group 1', 
            check_overlap = TRUE, color = 'red', size = 6) +
  theme_void()

< img src="https://i.sstatic.net/lNcsd.png" alt="在此处输入图像描述">

You're not actually using ggtree to plot here. If you wish to draw your tree with ggtree you could do something like this:

library(ggtree)
library(ggplot2)

set.seed(123)
tree <- rtree(30)

ggplot(tree) + 
  geom_tree() +
  geom_tiplab() +
  geom_text(aes(0.5, 20), label = 'Group 1', 
            check_overlap = TRUE, color = 'red', size = 6) +
  theme_void()

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文