簡體   English   中英

ggtree:如何以最簡單的方式生成 label 個樹枝

[英]ggtree: how to label tree branches in the simplest way

我想 label 樹上的特定分支(例如,“第 1 組”),但我沒有找到特定的 function 來執行此操作。 有任何想法嗎?

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

在此處輸入圖像描述

您實際上並沒有在這里使用ggtree到 plot。 如果你想用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()

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM