thomasp85 / ggraph

Grammar of Graph Graphics
https://ggraph.data-imaginist.com
Other
1.08k stars 116 forks source link

Error in facet_graph with one dimension #313

Closed eveyp closed 2 years ago

eveyp commented 2 years ago

I'm getting an error everytime I try to use facet_graph() with only one dimension. These plots work fine with facet_grid() instead of facet_graph() so I'm not sure what the issue is.

Here's an example that leads to the error:

library(ggraph)
library(tidygraph)
library(tibble)

nodes = tibble(
  id = 1:10,
  type = c(rep("A", 3), rep("B", 1), rep("C", 6))
)

edges = tibble(
  from = c(1, 5, 6, 7, 9),
  to =   c(2, 7, 8, 9, 10)
)

tbl_graph(nodes, edges) %>% 
  ggraph(layout = "tree", flip.y = FALSE) +
  geom_node_point() +
  geom_edge_link() +
  facet_graph(type ~ ., row_type = "node", scales = "free_y", space = "free")