Thanks a lot guys, for all the answers. On the plot method of igraph, if i use rescale=F and i got the desired effect. Below are my code with the desired effect.
I read the manual, but i think i did not notice the point, i think i got used to xlim argument and this mislead me to the confusion, i'm sorry for the confusion. Anyway, thanks again for the patience, you helped me a lot. Best wishes Augusto Ribas ############################################################################ library(ape) library(igraph) set.seed(15) pol.s<-paste("Polinizador",1:5) flor.s<-paste("Flor",1:5) dados<-data.frame(pol=sample(pol.s,15,replace=T),flor=sample(flor.s,15,replace=T)) dados.g <-graph.data.frame(unique(dados), directed=F) posicao<-matrix(c(rep(c(4,8),each=5),rep(1:5,2)),ncol=2,nrow=10) plot(rtree(5),show.tip.label=F,use.edge.length = F,edge.width = 2,x.lim=c(0,10)) plot(dados.g, layout=posicao,vertex.color=rep(c("green","yellow"),each=5),vertex.size=35, vertex.label=NA,edge.color="black",edge.width=3,add=T,rescale=F) axis(1) axis(2) ################################################################################## 2014-03-19 18:50 GMT-04:00 Klaus Schliep <klaus.schl...@gmail.com>: > Dear Augusto, > > below are some comments about plot.phyo. > > Tchau > Klaus > > On Wed, Mar 19, 2014 at 10:35 PM, Augusto Ribas <ribas....@gmail.com>wrote: > >> Hello. >> >> I'm trying to combine 2 plots, a phylogeny and a network. >> but i'm having a little problems. >> >> i have two question about the phylogeny plot and one about igraph, but >> about igraph i'll look for help on the package forum too, so no worries, >> but in case someone know igraph, the question is here too. >> The code for the figures i refer are in the end of the message. >> >> >> About plot.phylo. >> >> Question 01. >> Look at figure 1, the tree are plotted and every tip have their >> coordinates >> in X and Y axis, i would like to know how to extract them, for example, >> tip >> 1 end at x=4 and y=1, tip 2 end at x=4, y=2, are there a way to easy >> extract that directly, to use for others purposes, like add others things >> to the plot? > > > This is probably all you need: > set.seed(15) > tree = rtree(5) > plotdata <- plot(tree,show.tip.label=F,use.edge.length = F,edge.width = 2) > plotinfo <- get("last_plot.phylo", envir = .PlotPhyloEnv) > plotdata > plotinfo > points(plotinfo$xx, plotinfo$yy) > nodelabels() > tiplabels() > > > >> Question 02 >> How do i control the x limits, for example, figure 1, the tree, i would >> like the x axis to begin in 0 and end in 15 for example, The tree occupy >> the 0 to 4 length in x axis, i would like to have empty space to put >> things >> (particularly a network with my parameters), so i just want some more >> space >> in the figure, i don't know how to control it or if i'm allowed to do so >> for this function. >> >> I tryed to use xlim=c(0,15) >> >> > plot(rtree(5),show.tip.label=F,use.edge.length = F,edge.width = >> 2,xlim=c(0,15)) >> Erro em plot.default(0, type = "n", xlim = x.lim, ylim = y.lim, xlab = "", >> : >> argumento formal "xlim" corresponde a mĂșltiplos argumentos especificados >> >> The argument for plot.phylo is called x.lim not xlim, reading the manual > sometimes helps ;) So this works: > > plot(rtree(5),show.tip.label=F,use.edge.length = F,edge.width =2, > x.lim=c(0,15)) > > >> But my guess is that the function already use it (the xlim argument), so i >> could not change it like this. >> Use par(mfrow=c(1,2)) or the layout() function do not allow me to glue >> perfectly the network and the tree, so how do i leave empty space to add >> things? >> >> Question 03. (no worries here, but just in case) >> The igraph plot function centralize the coordinates in and limits the plot >> between 1 and -1, both for x and y axis, how do i disable this feature, >> for >> example, when i create the matrix posicao with the positions that i desire >> for the vertices(nodes), when i say vertice 1 to be at x=1 and y=1, it >> really be there, and now be recalculated to stay between -1 and 1. >> >> >> >> >> Sample code >> >> #packages >> library(ape) >> library(igraph) >> >> >> #generate some data >> set.seed(15) >> pol.s<-paste("Polinizador",1:5) >> flor.s<-paste("Flor",1:5) >> >> dados<-data.frame(pol=sample(pol.s,15,replace=T),flor=sample(flor.s,15,replace=T)) >> >> dados.g <-graph.data.frame(unique(dados), directed=F) >> >> #position matrix, each line is the position of a vertice(node) >> posicao<-matrix(c(rep(1:2,each=5),rep(1:5,2)),ncol=2,nrow=10) >> >> >> #Figure 1 >> plot(rtree(5),show.tip.label=F,use.edge.length = F,edge.width = 2) >> axis(1) >> axis(2) >> >> #figure 2 >> plot(dados.g, >> layout=posicao+1,vertex.color=rep(c("green","yellow"),each=5), >> vertex.shape=rep(c("square","circle"),each=5),vertex.size=35, >> vertex.label=c(paste("Pol",1:5),paste("Flor",1:5)),edge.color="black", >> edge.width=3) >> axis(1) >> axis(2) >> >> >> #figure 3 >> #i would like to glues these two guys, but i need to better control the >> arguments >> #and i dont know how :( >> plot(rtree(5),show.tip.label=F,use.edge.length = F,edge.width = 2) >> par(new=T) >> plot(dados.g, layout=posicao,vertex.color=rep(c("green","yellow"),each=5), >> vertex.shape=rep(c("square","circle"),each=5),vertex.size=35, >> vertex.label=c(paste("Pol",1:5),paste("Flor",1:5)),edge.color="black", >> edge.width=3,add=T) >> >> -- >> Grato >> Augusto C. A. Ribas >> >> Site Pessoal: http://recologia.com.br/ <http://augustoribas.heliohost.org >> > >> >> Github: https://github.com/Squiercg >> Lattes: http://lattes.cnpq.br/7355685961127056 >> >> [[alternative HTML version deleted]] >> >> >> _______________________________________________ >> R-sig-phylo mailing list - R-sig-phylo@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo >> Searchable archive at >> http://www.mail-archive.com/r-sig-phylo@r-project.org/ >> > > > > -- > Klaus Schliep > Phylogenomics Lab at the University of Vigo, Spain > http://darwin.uvigo.es/kschliep/ > > -- Grato Augusto C. A. Ribas Site Pessoal: http://recologia.com.br/ <http://augustoribas.heliohost.org> Github: https://github.com/Squiercg Lattes: http://lattes.cnpq.br/7355685961127056 [[alternative HTML version deleted]]
_______________________________________________ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/