R 在ggplot方面中添加表

R 在ggplot方面中添加表,r,ggplot2,facet,R,Ggplot2,Facet,我需要帮助,以便在我的图形中添加类似geom_表的内容 以下是我可以得出的数字: 以下是我使用的代码: library(ggtree) library(ggplot2) library(ggstance) tr <- rtree(30) p <- ggtree(tr) #df1<-dput(read.table("/Users/user/Desktop/test_data.txt",sep=";",h=T)) p1 <- p %

我需要帮助,以便在我的图形中添加类似geom_表的内容

以下是我可以得出的数字:

以下是我使用的代码:

library(ggtree)
library(ggplot2)
library(ggstance)

tr <- rtree(30)
p <- ggtree(tr)
#df1<-dput(read.table("/Users/user/Desktop/test_data.txt",sep=";",h=T))
p1 <- p %<+% df1 + geom_tippoint(aes(color=location))
d2 <- data.frame(id=tr$tip.label, val=rnorm(30, sd=3))
p2 <- facet_plot(p1, panel="dot", data=d2, geom=geom_point, aes(x=val), color='firebrick') + theme_tree2()
d3 <- data.frame(id = rep(tr$tip.label, each=2),
                 value = abs(rnorm(60, mean=100, sd=50)),
                 category = rep(LETTERS[1:2], 30))
p3 <- facet_plot(p2, panel = 'Stacked Barplot', data = d3, 
                 geom = geom_barh, 
                 mapping = aes(x = value, fill = as.factor(category)), 
                 stat='identity' ) 

我不熟悉ggtree包或它的语法,但一些尝试和错误表明,您可以简单地使用
geom_text
geom_bar
进行扩展,以获得类似于表的facet

库(ggtree)
图书馆(GG2)
图书馆(GGSTANTE)

谢谢你的帮助^
structure(list(id = structure(c(5L, 15L, 29L, 18L, 24L, 21L, 
13L, 11L, 8L, 25L, 23L, 9L, 16L, 3L, 6L, 2L, 20L, 27L, 30L, 17L, 
14L, 4L, 1L, 7L, 22L, 28L, 10L, 12L, 26L, 19L), .Label = c("t1", 
"t10", "t11", "t12", "t13", "t14", "t15", "t16", "t17", "t18", 
"t19", "t2", "t20", "t21", "t22", "t23", "t24", "t25", "t26", 
"t27", "t28", "t29", "t3", "t30", "t4", "t5", "t6", "t7", "t8", 
"t9"), class = "factor"), location = structure(c(1L, 3L, 2L, 
1L, 2L, 3L, 3L, 2L, 3L, 2L, 3L, 3L, 2L, 2L, 1L, 1L, 3L, 2L, 1L, 
1L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 1L, 1L), .Label = c("CZ", 
"GZ", "HK"), class = "factor"), Value = c(NA, 10L, NA, 12L, NA, 
NA, NA, NA, NA, NA, NA, NA, 45L, 89L, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, 80L, NA, NA, NA, NA)), class = "data.frame", row.names = c(NA, 
-30L))