我有以下代码,感谢@G.Grothendieck 的回答 https://stackoverflow.com/questions/69620275/how-to-display-a-simple-tree-in-r-graphically/69620437#69620437
library(igraph)
DF <- data.frame(in. = 1:6, out. = c(3, 3, 5, 5, 7, 7))
g <- graph_from_edgelist(as.matrix(DF[2:1]))
lay <- layout_as_tree(g)
plot(as.undirected(g), layout = lay %*% diag(c(1, -1)))
现在,我需要在此基础上向该图中添加一些文本:
DF <- data.frame(in. = 1:6, out. = c(3, 3, 5, 5, 7, 7),
date = c('2019-11-01', '2019-11-01', '2020-01-01', '2020-01-01', '2020-12-31', '2020-12-31') )
我希望将 2019-11-01 显示在顶层的一侧(或者更好,在每个级别的两个节点之间),然后在下一级显示 2020-01-01,然后将 '2020-12-下一层是31`,底层什么也没有。
这可能吗 ?