Hi Emmanuel, Rafael, & Elizabeth.

Some phytools functions suffer from the precisely the same issue identified by Elizabeth as phytools::plotTree and phytools::plotSimmap also have a plot=FALSE option, & Rafael's solution seems to work. For instance, I posted an example to my blog here:

http://blog.phytools.org/2017/09/possible-solution-for-functions-that.html

I'm not sure if this means I won't run into difficulty with this solution, but I'm eager to hear why.

- Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 9/26/2017 11:52 AM, Emmanuel Paradis wrote:
Hi Rafael,

This is used in example(phydataplot), but once you called plot(tree,
plot = FALSE), you cannot change x.lim, y.lim, etc. You can notice in
these examples that these parameters are (most of the time) not nicely
set: this is because the data are simulated. If you work interactively,
it's quite easy to find the appropriate value of x.lim with a few tries
for a given data set. Then, once this is saved in a script, it's
possible to repeat the plot and adjust the other parameters (colours,
legend, ...)

Best,

Emmanuel

Le 26/09/2017 à 18:10, Rafael Maia a écrit :
Hi Elizabeth,

I ran into a similar problem recently (with another package) and a
simple solution that worked for me is to call par(new=TRUE) before
your plot=TRUE plot. So something like:

  pdf('test.pdf')
  plot(tree, plot=FALSE)
  par(new=TRUE)
  plot(tree, plot=TRUE)
  dev.off()

HTH

Best,
Rafael Maia
—
Junior Fellow, Simons Society of Fellows
Rubenstein Lab, Columbia University
Department of Ecology, Evolution and Environmental Biology
New York, NY
http://www.rafaelmaia.net

On Sep 26, 2017, at 9:03 AM, Emmanuel Paradis
<emmanuel.para...@ird.fr <mailto:emmanuel.para...@ird.fr>> wrote:

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()
X11cairo
      2
R> lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
R> lastPP
$type
[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:

example(phydataplot)

HTH

Best,

Emmanuel

Le 26/09/2017 à 14:58, Elizabeth Purdom a écrit :
Hello,
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
: http://f.security-mail.net/302lu3ZCAL7


_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
<mailto: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/




_______________________________________________
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/

_______________________________________________
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/

Reply via email to