Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: having an absolute location custom layout. #375

Open
OmarAshkar opened this issue Jul 11, 2024 · 1 comment
Open

question: having an absolute location custom layout. #375

OmarAshkar opened this issue Jul 11, 2024 · 1 comment

Comments

@OmarAshkar
Copy link

Hello,

I am trying to have a specific absolute location layout. Is it possible?

For example I have this code that will create at tree with top-down

graph <- as_tbl_graph(
data.frame( from = c("1", "1", "1", "50", "5"),  
            to = c("200", "100", "50", "5", "2")) 
)
graph

layout <- create_layout(graph, layout = "tree" )
ggraph(graph, layout) + 
  geom_edge_bend() + 
  geom_node_point() + 
  geom_node_label(aes(label = as.data.frame(graph)$name))

What I am looking for is

  1. right to left orientation instead of top-down.
  2. All "to" nodes must be aligned on top of each other
  3. As you noticed, the branching sometimes happens from the same node, so may be different edges can be specified like arc if this happened.

I really appreciate some guidance on this.

Thank you!

@schochastics
Copy link
Contributor

Not exactly sure what you are looking for, but you can specify a layout manually

x <- c(-3, -2, -1, -2, -2, 0)
y <- c(0, -1, -1, 0, 1, -1)
ggraph(graph, "manual", x = x,y = y) + 
  geom_edge_bend() + 
  geom_node_point() + 
  geom_node_label(aes(label = as.data.frame(graph)$name))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants