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

Fix position #1

Closed
jalapic opened this Issue Jan 13, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@jalapic
Copy link

jalapic commented Jan 13, 2016

Looking forward to the development of this package!. This is more of a feature request than an issue. I was just wondering if it is or will be possible to fix the position of a network layout. i.e. if you were to re-execute this code:

ggraph(graph = gr, layout = 'fr') + geom_edge_link(aes(size = weight), color = 'grey', alpha = 0.5) + geom_node_point(aes(color = class), size = 10) + coord_fixed() + ggforce::theme_no_axes()

that the layout would always be the same? I don't think this is doable through igraph and perhaps that means also not possible here? My rationale is because it would be great to be able to update the same network temporally showing how edges change - this would only make sense visually if the nodes remain in the same place.

@thomasp85

This comment has been minimized.

Copy link
Owner

thomasp85 commented Jan 13, 2016

This is already possible if you create the layout up-front:

layout <- createLayout(graph = gr, layout = 'fr')
ggraph(data=layout) + geom_edge_link() # etc...

@thomasp85 thomasp85 closed this Jan 13, 2016

@thomasp85

This comment has been minimized.

Copy link
Owner

thomasp85 commented Jan 13, 2016

Ah... I just reread your post. You want to plot - change the graph and then plot again..? That is not fully as straightforward yet, but I'll most certainly add a layout = 'manual' in the near future. You can achieve it in igraph by supplying a two-column matrix as the layout in the plot function instead of the name of a layout function...

Currently with ggraph the workaround would be:

layout <- createLayout(graph = gr, layout = 'fr')
ggraph(data=layout) + geom_edge_link() # etc...

# do something to graph edges

attr(layout, 'graph') <- gr
ggraph(data=layout) + geom_edge_link() # etc...
@thomasp85

This comment has been minimized.

Copy link
Owner

thomasp85 commented Jan 13, 2016

Just as a bonus for filing the first issue I implemented it for you right away in 1a64476

Now do:

# do something to create a data.frame with x and y positions for your nodes (e.g. using createLayout)
ggraph(graph = gr, layout = 'manual', node.positions = nodes) + geom_edge_link()
# Where 'nodes' are the data.frame with the node position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment