I want to create a community plot in ggraph. Is this possible?
I made a version of it using the base plot function and igraph. Not sure how I can do this using ggraph.
I want to create a community plot in ggraph. Is this possible?
I made a version of it using the base plot function and igraph. Not sure how I can do this using ggraph.
the ggforce package contains geom_mark_x() geoms that can be applied to ggraph networks. geom_mark_hull() looks closest to your example.
for example:
gr <- as_tbl_graph(highschool) |>
mutate(
feat1 = sample(LETTERS[1:3], n(), replace = TRUE),
feat2 = sample(LETTERS[1:8], n(), replace = TRUE)
) |>
mutate_at(vars(feat1, feat2), as.factor)
ggraph(gr, layout='kk', circular=F) + geom_mark_hull(aes(x,y,fill=feat1)) + geom_node_point() + geom_node_text(aes(label=name)) + geom_edge_link()
the fill aesthetic determines which color each node gets!