ggraph
ggraph copied to clipboard
Allowing half manual layouts?
Many thanks for such wonderful packages I been using them more and more!
However, I can't find a functionality I think could be useful.I would like to be able to select some nodes and distribute at certain positions and let other nodes using the automagically positions. I'm not sure how to do that using the manual layout. Could that be done?
Something on these lines:
# To allow the nodes of to be in a square
# in node data (following tidygraph) there would be a column describing the type of the node
ggraph(graph, layout = 'kk') +
geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE) +
geom_node_point(select = type == "A" , position = "square") # Or circle
# To allow the nodes of some genes to be as it would be on a map or from cmdscale
df <- cmdscale(matrix_distances_between_genes)
ggraph(graph, layout = 'kk') +
geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE) +
geom_node_point(select = type == "A" , position = df)
Of course, this could be changed and a better function names could be selected. Perhaps it is already doable with some combination of plottings and I might have missed. I hope you can give me directions. Thanks
This is something that needs to be implemented as a new layout. You could probably cook a force-directed one up pretty quickly using the particles package
Many thanks for the suggestion
@schochastics is this something that could be added as (yet another) constrained stress layout?
I think so. I will put it on the graphlayouts todo list
This is now implemented in graphlayouts
@schochastics does the implementation support partial fixes, e.g. that one node has a fixed x
coord but no fix on the y coordinate and so on. Or does the fixtures need to be complete?
Yes. The fixed coordinates can be arbitrary and dont need to include both x and y values
great, so if all x coordinates are provided and no y-coordinates are provided it behaves exactly as layout_with_constrained_stress()
?
Yes, I verfied that :-)