创建 ggraph circlepack 布局需要什么数据格式?它似乎需要一个层次结构。
我通常尝试了顶点和节点,这显然不起作用。
library(ggraph)
library(igraph)
edges=data.frame(from=c('a','b','c'), to= c('c','a','d'))
vertices=data.frame(nodes=c('a','b','c','d'), weight=c(1,2,3,4))
graph <- graph_from_data_frame(edges, vertices = vertices)
ggraph(graph, 'circlepack', weight = 'size') +
geom_node_circle(size = 0.25, n = 50) +
coord_fixed()
然后我尝试了一个也不起作用的树状图对象。如果我想在压缩圆中显示几个带有子项目的组,我应该如何构建图形对象?
数据框更像这样
df <- data.frame(group=c("a","a","b","b","b"), subitem=c("x","y","z,"u","v"), size=c(6,2,3,2,5))