From e64b298d9074561ebd0b07859e959fcc0dc980b2 Mon Sep 17 00:00:00 2001 From: paradis Date: Tue, 29 Mar 2011 09:19:17 +0000 Subject: [PATCH] new option 'draw' in plot.phylo() git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@155 6e262413-ae40-0410-9e79-b911bd7a66b7 --- ChangeLog | 11 +++++++++++ DESCRIPTION | 4 ++-- R/plot.phylo.R | 24 ++++++++++++++---------- man/plot.phylo.Rd | 5 ++++- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40d2a95..c702b68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ + CHANGES IN APE VERSION 2.7-2 + + +NEW FEATURES + + o plot.phylo() has a new option 'draw = TRUE'. If FALSE, the tree + is not plotted but the graphical device is set and the + coordinates are saved as normal. + + + CHANGES IN APE VERSION 2.7-1 diff --git a/DESCRIPTION b/DESCRIPTION index 6da064b..90bd55b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape -Version: 2.7-1 -Date: 2011-03-26 +Version: 2.7-2 +Date: 2011-03-29 Title: Analyses of Phylogenetics and Evolution Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, Christoph Heibl, Daniel Lawson, Vincent Lefort, Pierre Legendre, Jim Lemon, Yvonnick Noel, Johan Nylander, Rainer Opgen-Rhein, Klaus Schliep, Korbinian Strimmer, Damien de Vienne Maintainer: Emmanuel Paradis diff --git a/R/plot.phylo.R b/R/plot.phylo.R index 18bba88..88380ff 100644 --- a/R/plot.phylo.R +++ b/R/plot.phylo.R @@ -1,4 +1,4 @@ -## plot.phylo.R (2011-03-23) +## plot.phylo.R (2011-03-29) ## Plot Phylogenies @@ -7,14 +7,15 @@ ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. -plot.phylo <- function(x, type = "phylogram", use.edge.length = TRUE, - node.pos = NULL, show.tip.label = TRUE, - show.node.label = FALSE, edge.color = "black", - edge.width = 1, edge.lty = 1, font = 3, cex = par("cex"), - adj = NULL, srt = 0, no.margin = FALSE, - root.edge = FALSE, label.offset = 0, underscore = FALSE, - x.lim = NULL, y.lim = NULL, direction = "rightwards", - lab4ut = "horizontal", tip.color = "black", ...) +plot.phylo <- + function(x, type = "phylogram", use.edge.length = TRUE, + node.pos = NULL, show.tip.label = TRUE, + show.node.label = FALSE, edge.color = "black", + edge.width = 1, edge.lty = 1, font = 3, cex = par("cex"), + adj = NULL, srt = 0, no.margin = FALSE, root.edge = FALSE, + label.offset = 0, underscore = FALSE, x.lim = NULL, + y.lim = NULL, direction = "rightwards", lab4ut = "horizontal", + tip.color = "black", draw = TRUE, ...) { Ntip <- length(x$tip.label) if (Ntip == 1) { @@ -278,6 +279,8 @@ plot.phylo <- function(x, type = "phylogram", use.edge.length = TRUE, } asp <- if (type %in% c("fan", "radial", "unrooted")) 1 else NA # fixes by Klaus Schliep (2008-03-28 and 2010-08-12) plot(0, type = "n", xlim = x.lim, ylim = y.lim, ann = FALSE, axes = FALSE, asp = asp, ...) + +if (draw) { if (is.null(adj)) adj <- if (phyloORclado && direction == "leftwards") 1 else 0 if (phyloORclado && show.tip.label) { @@ -288,7 +291,7 @@ plot.phylo <- function(x, type = "phylogram", use.edge.length = TRUE, } if (direction == "leftwards") { lox <- -label.offset - MAXSTRING * 1.05 * (1 - adj) - #xx <- xx + MAXSTRING + ##xx <- xx + MAXSTRING } if (!horizontal) { psr <- par("usr") @@ -403,6 +406,7 @@ plot.phylo <- function(x, type = "phylogram", use.edge.length = TRUE, if (show.node.label) text(xx[ROOT:length(xx)] + label.offset, yy[ROOT:length(yy)], x$node.label, adj = adj, font = font, srt = srt, cex = cex) +} L <- list(type = type, use.edge.length = use.edge.length, node.pos = node.pos, show.tip.label = show.tip.label, show.node.label = show.node.label, font = font, diff --git a/man/plot.phylo.Rd b/man/plot.phylo.Rd index f6a137c..2a07ba0 100644 --- a/man/plot.phylo.Rd +++ b/man/plot.phylo.Rd @@ -9,7 +9,7 @@ cex = par("cex"), adj = NULL, srt = 0, no.margin = FALSE, root.edge = FALSE, label.offset = 0, underscore = FALSE, x.lim = NULL, y.lim = NULL, direction = "rightwards", - lab4ut = "horizontal", tip.color = "black", ...) + lab4ut = "horizontal", tip.color = "black", draw = TRUE, ...) \method{plot}{multiPhylo}(x, layout = 1, ...) } \arguments{ @@ -90,6 +90,9 @@ \code{type = "unrooted"}.} \item{tip.color}{the colours used for the tip labels, eventually recycled (see examples).} + \item{draw}{a logical controlling whether to draw the tree. If + \code{FALSE}, the graphical device is set as if the tree was + plotted, and the coordinates are saved as well.} \item{layout}{the number of trees to be plotted simultaneously.} \item{\dots}{further arguments to be passed to \code{plot} or to \code{plot.phylo}.} -- 2.39.2