Hi, You don't need any function for merging the layouts; layout_components() will do this for you:
> library(igraph) > g <- make_ring(5) * 4 > layout <- layout_components(g, layout=layout_with_fr) > plot(g, layout=layout) Basically, layout_components will decompose the graph into its connected components, then call the given layout function (layout_with_fr in the above example) for all the components, merges the layouts, and returns a single unified layout that is suitable for the original graph. Any additional arguments supplied to layout_components() are forwarded to the actual component-wise layout function. All the best, T. On Mon, Mar 7, 2016 at 1:20 PM, Mostowy, Rafal J <[email protected]> wrote: > Hi Tamas, > > Thanks a lot for your reply. This sounds like a y complicated solution of the > problem. I'm saying this because before I would just vary one parameter and > get the result I wanted, whereas now I'd need to design an entire function to > merge the connected components. Is there a simple way of doing that? Would > you be willing to give a simple exaple? The one on the help page doesn't seem > to do what I need. > > Thanks a lot, > R > >> On 5 Mar 2016, at 20:48, Tamas Nepusz <[email protected]> wrote: >> >> Hi, >> >> The new implementation of the Fruchterman-Reingold layout does not >> have the "area" option any more, but you can try using >> layout_components() - this will decompose the graph into connected >> components first, lay out the connected components separately, and >> then merge the layouts. >> >> T. >> >> >> On Sat, Mar 5, 2016 at 2:56 PM, Mostowy, Rafal J >> <[email protected]> wrote: >>> I'm trying to optimise the layout of a network I'm constructing with the >>> following code: >>> >>> gr <- read.table("data.txt", header = F, stringsAsFactors = F) >>> node.names <- gr[,1] >>> node.names <- toupper(substr(node.names, 2, nchar(node.names))) >>> gr <- gr[,-1] >>> edge.table.index <- which(gr>0.5, arr.ind=T) >>> d <- data.frame(first = node.names[edge.table.index[,1]], second = >>> node.names[edge.table.index[,2]]) >>> g <- graph.data.frame(d, directed=F) >>> g[from=V(g), to=V(g)] <- 0 >>> layout.g <- layout.fruchterman.reingold(g) >>> plot(g, layout = layout.g, vertex.size = 5, vertex.label.cex=.7, >>> vertex.color = "lightblue", vertex.label.family = "sans", >>> edge.color="black", vertex.frame.color= "white") >>> >>> In particular, what I'm trying to do is decrease the area on which the >>> nodes are displayed such that the connected components are closer together. >>> Previous versions of igraph had the option 'area' in the >>> layout.fruchterman.reingold() function but this doesn't seem to be the case >>> anymore. I've tried playing with various options like vertex size, vertex >>> font size and width/height of the exported pdf file but they don't really >>> do the trick. >>> >>> Does anyone have a suggestion? I’m attaching a link to the data. >>> >>> Thanks, >>> Rafal >>> >>> >>> >>> >>> >>> ________________ >>> Rafal Mostowy, PhD >>> Junior Research Fellow >>> Department of Infectious Disease Epidemiology >>> Imperial College London >>> St Mary's Campus >>> Norfolk Place >>> London W2 1PG >>> email: [email protected] >>> twitter: @RafalMostowy >>> website: http://rmostowy.wordpress.com >>> >>> >>> >>> _______________________________________________ >>> igraph-help mailing list >>> [email protected] >>> https://lists.nongnu.org/mailman/listinfo/igraph-help >> >> _______________________________________________ >> igraph-help mailing list >> [email protected] >> https://lists.nongnu.org/mailman/listinfo/igraph-help > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help _______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
