Hi Elizabeth,

You can use directly the functions behind the calculations of the coordinates; they are documented together: ?node.depth. But this will not give the final coordinates since more calculations are needed depending on the widths of the labels, etc.

Another possibility could be to plot the tree in a temporary file and get the settings afterwards, eg:

R> tmpf <- tempfile()
R> pdf(tmpf)
R> plot(rtree(100))
R> dev.off()
R> lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
R> lastPP
[1] "phylogram"

R> unlink(tmpf) # optional since it's deleted when R is closed

Just for the record, if some users wonder about the usefulness of the option plot=FALSE, see some examples in:





Le 26/09/2017 à 14:58, Elizabeth Purdom a écrit :

I am writing a function that calls plot.phylo in the ape package with the 
option plot=FALSE. I then do some calculations with the output (the calculated 
coordinates), and then make another call to plot.phylo with plot=TRUE. If I do 
this, then the plot=FALSE option creates a blank plot, which is the result that 
is clearly documented in the help pages.

However, I do not want this blank plot, because I am saving the result (the 
second call to plot.phylo) to a pdf, and so the pdf has a blank page before the 
plot I want. And since I’m calling this in a function, I can’t “wait” for the 
second plot (a similar problem occurs if you run it in a knitr document)

Is there a way to get the output from plot.phylo with all of the coordinates, 
etc. without having to have the blank plot? (I do not want an option to “add” 
the plot to the blank plot, if it exists, because I am doing these calculations 
so that in my next call I can change the x.lim options so the tree only takes 
up a fraction of the plot, so I need to reset the par, etc., and not just draw 
on the original coordinates set up by the blank plot)

Thank you,
Elizabeth Purdom

Pour nous remonter une erreur de filtrage, veuillez vous rendre ici : 

R-sig-phylo mailing list - R-sig-phylo@r-project.org
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to