Seems like a bug in igraph, although I have no time now to check. Here is a workaround:
plot(NA, type="n", xlim=range(V(gs)$x), ylim=c(0,1), axes=FALSE, xlab="", ylab="") plot (gs, vertex.size=2, vertex.label=NA, rescale=FALSE, xlim=range (V(gs)$x), ylim=c(0,1), edge.width= (E(gs)$weight)^6, layout= cbind (V(gs)$x, V(gs)$y), add=TRUE) G. On Wed, Nov 27, 2013 at 11:43 AM, Hermann Norpois <[email protected]> wrote: > Thanks for your answer. > > I tried and solved some problems. But there are new problems. There is a > suboptimal resolution in the y-dimension. And I cannot change the y-scale by > ylim: > > plot (gs, vertex.size=2, vertex.label=NA, rescale=FALSE, xlim=range > (V(gs)$x), ylim= range (0,1), edge.width= (E(gs)$weight)^6, layout= cbind > (V(gs)$x, V(gs)$y)) > axis (1) > axis (2) #result: plot 1 > > > plot (gs, vertex.size=2, vertex.label=NA, edge.width= (E(gs)$weight)^6, > layout= cbind (V(gs)$x, V(gs)$y)) > axis (1) > axis (2) #result: plot 2 > > Actually I want the graphic of plot 2 and the x-axis of plot 1. > > dput (gs) > structure(list(5, FALSE, c(1, 2, 3, 4, 2, 3, 4, 3, 4, 4), c(0, > 0, 0, 0, 1, 1, 1, 2, 2, 3), c(0, 1, 4, 2, 5, 7, 3, 6, 8, 9), > c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), c(0, 0, 1, 3, 6, 10), c(0, > 4, 7, 9, 10, 10), list(c(1, 0, 1), structure(list(), .Names = > character(0)), > structure(list(name = c("rs59433790", "rs79037", "rs17343978", > "rs67257945", "rs55903329"), x = c(27428860L, 27433179L, > 27433885L, 27434791L, 27436699L), y = c(0.8205112299125, > 0.9363622429465, 0.93638580294825, 0.94247291459475, > 0.78999608053825)), .Names = c("name", "x", "y")), structure(list( > weight = c(0.911066, 0.911768, 0.919415, 0.827461, > 0.983026, 0.991462, 0.892149, 0.991467, 0.891518, > 0.899993), y = c(0.925873823199, 0.787782242488667, > 0.927452731221353, 0.894941333333333, 0.632980042374762, > 0.634975016479238, 0.768939143570769, 0.883051666666667, > 0.747102777275171, 0.995810294117647), color = c("red", > "red", "red", "red", "red", "red", "red", "red", > "red", "red")), .Names = c("weight", "y", "color" > > )))), class = "igraph") > > Thanks > Hermann > > > > 2013/11/26 Gábor Csárdi <[email protected]> >> >> On Tue, Nov 26, 2013 at 10:26 AM, Hermann Norpois <[email protected]> >> wrote: >> > I am sorry I did not get it. >> > If I use rescale=FALSE my plot is empty. >> >> You also need to set the xlim and ylim parameters, because that also >> defaults to (-1,1). >> >> > Actually I would like to change the rescale parameters. Is that >> > possible, >> > i.e. >> > rescaleparameters = V(gs)$x >> >> No, that's not possible. Rescale the layout for yourself, and then set >> these limits in xlim and ylim. >> >> Btw. if you include code this way, that is somewhat a pain to try, >> because the > prompt makes it impossible to copy and paste. It is best >> to include some code that we can just copy and paste into R, without >> needing to edit it in emacs. >> >> G. >> >> > My try: >> > plot (gs, vertex.size=2, vertex.label=NA,rescale=FALSE, edge.width= >> > (E(gs)$weight)^6, layout=cbind (V(gs)$x, V(gs)$y)) >> > >> >> dput (gs) >> > structure(list(2, FALSE, 1, 0, 0, 0, c(0, 0, 1), c(0, 1, 1), >> > list(c(1, 0, 1), structure(list(), .Names = character(0)), >> > structure(list(name = c("rs744016", "rs763273"), x = >> > c(27042106L, >> > 27043594L), y = c(0.6445235948615, 0.6229189950958)), .Names = >> > c("name", >> > "x", "y")), structure(list(weight = 0.986597, y = 0.7704755, >> > color = "red"), .Names = c("weight", "y", "color" >> > )))), class = "igraph") >> >> class (gs) >> > [1] "igraph" >> >> plot (gs, vertex.size=2, vertex.label=NA,rescale=FALSE, edge.width= >> >> (E(gs)$weight)^6, layout=cbind (V(gs)$x, V(gs)$y)) >> >> axis (1, at=1:10) # Does not change anything. >> >> plot (gs, vertex.size=2, vertex.label=NA, edge.width= >> >> (E(gs)$weight)^6, >> >> layout=cbind (V(gs)$x, V(gs)$y)) >> >> >> > >> > >> > 2013/11/26 Gábor Csárdi <[email protected]> >> >> >> >> Hi, >> >> >> >> no, this is an igraph thing, igraph rescales layouts to (-1, 1), >> >> unless you specify the rescale=FALSE: >> >> >> >> http://igraph.sourceforge.net/doc/R/plot.common.html >> >> >> >> Gabor >> >> >> >> On Tue, Nov 26, 2013 at 9:53 AM, Hermann Norpois <[email protected]> >> >> wrote: >> >> > Hello, >> >> > >> >> > I want to have an x-axis with x-values refering to V(g)$x. >> >> > >> >> > How does this work? >> >> > >> >> > I tried >> >> > axis (1, at=V(g)$x) without an effect. >> >> > >> >> > dput (axis (1)) has the following output: >> >> > c(-1, -0.5, 0, 0.5, 1) >> >> > >> >> > How can I change this? I guess it is more a classical R-question ... >> >> > >> >> > thanks >> >> > Hermann >> >> > >> >> > >> >> > _______________________________________________ >> >> > 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 > > > > _______________________________________________ > 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
