I am trying to create a graph using ggraph's circlepack layout in R.
The code I am using is below.
df <- data.frame(PID = c("root", "c11111", "c22222", "c11111", "c11111"),
ID = c("c11111", "c22222", "s33333", "c44444", "c55555"),
size = c(1, 20000, 10000, 1, 1))
vertices <- df %>%
distinct(ID, size) %>%
add_row(ID = "root", size = 0)
mygraph <- graph_from_data_frame(df, vertices = vertices)
ggraph(mygraph, layout = 'circlepack') +
geom_node_circle(aes(fill = size)) +
theme_void() +
geom_node_label(aes(label = name))
I am not sure why c22222 is not appearing within c33333 - I'm only seeing c33333.
I'd greatly appreciate any advice or ideas about what's going on.
Your code is actually correct, but your labels are overlapping If you add some jitter to your plot you'll see c22222
Note this plot currently does not use the
size
property of your graph. You should addweight=size