Permalink
Browse files

a few more fixes to do with font sizes in plot.cophylo method

  • Loading branch information...
liamrevell committed Apr 24, 2016
1 parent 5072438 commit 7f9646251bc5ddcd1eb645732fe55ac80a2bc9a6
Showing with 10 additions and 7 deletions.
  1. +9 −6 R/cophylo.R
  2. +1 −1 man/cophylo.Rd
View
@@ -113,7 +113,7 @@ makelinks<-function(obj,x){
}
## plot an object of class "cophylo"
## written by Liam J. Revell 2015
## written by Liam J. Revell 2015, 2016
plot.cophylo<-function(x,...){
plot.new()
if(hasArg(mar)) mar<-list(...)$mar
@@ -128,18 +128,21 @@ plot.cophylo<-function(x,...){
par(mar=mar)
plot.window(xlim=xlim,ylim=ylim)
leftArgs<-rightArgs<-obj
if(!is.null(obj$fsize)&&length(obj$fsize)>1){
leftArgs$fsize<-obj$fsize[1]
rightArgs$fsize<-obj$fsize[2]
}
if(!is.null(obj$fsize)){
if(length(obj$fsize)>1){
leftArgs$fsize<-obj$fsize[1]
rightArgs$fsize<-obj$fsize[2]
sb.fsize<- if(length(obj$fsize)>2) obj$fsize[3] else 1
} else sb.fsize<-1
} else sb.fsize<-1
x1<-do.call("phylogram",c(list(tree=x$trees[[1]],part=0.4),leftArgs))
left<-get("last_plot.phylo",envir=.PlotPhyloEnv)
x2<-do.call("phylogram",c(list(tree=x$trees[[2]],part=0.4,
direction="leftwards"),rightArgs))
right<-get("last_plot.phylo",envir=.PlotPhyloEnv)
if(!is.null(x$assoc)) makelinks(x,c(x1,x2))
else cat("No associations provided.\n")
if(any(scale.bar>0)) add.scalebar(x,scale.bar,fsize)
if(any(scale.bar>0)) add.scalebar(x,scale.bar,sb.fsize)
assign("last_plot.cophylo",list(left=left,right=right),envir=.PlotPhyloEnv)
}
View
@@ -12,7 +12,7 @@ cophylo(tr1, tr2, assoc=NULL, rotate=TRUE, ...)
\item{assoc}{matrix containing the tip labels in \code{tr1} to match to the tip labels in \code{tr2}. Note that not all labels in either tree need to be included; and, furthermore, one label in \code{tr1} can be matched with more than one label in \code{tr2}, or vice versa.}
\item{rotate}{logical argument indicating whether nodes on both trees should be rotated to attempt to match in vertical position.}
\item{x}{in the case of \code{plot.cophylo}, an object of class \code{"cophylo"} to be plotted.}
\item{...}{optional arguments to be passed to \code{\link{tipRotate}}, or, in the case of \code{plot.cophylo}, to the internally used tree plotting function, \code{phylogram}. \code{phylogram} takes similar arguments to \code{\link{plotSimmap}}, such as \code{fsize}, \code{ftype}, \code{lwd}, and \code{pts}, though not all options from \code{plotSimmap} and \code{plotTree} are available. In addition, the optional argument \code{scale.bar}, which should be a vector containing the lengths of the scale bars desired for the right & left trees, will add scale bars to the plot when supplied to \code{plot.cophylo}.}
\item{...}{optional arguments to be passed to \code{\link{tipRotate}}, or, in the case of \code{plot.cophylo}, to the internally used tree plotting function, \code{phylogram}. \code{phylogram} takes similar arguments to \code{\link{plotSimmap}}, such as \code{fsize}, \code{ftype}, \code{lwd}, and \code{pts}, though not all options from \code{plotSimmap} and \code{plotTree} are available. If \code{fsize} is supplied as a vector, different size fonts for the left & right facing trees may be used. In addition, the optional argument \code{scale.bar}, which should be a vector containing the lengths of the scale bars desired for the right & left trees, will add scale bars to the plot when supplied to \code{plot.cophylo}.}
}
\description{
This function creates an object of class \code{"cophylo"} or, in the case of \code{plot.cophylo}, plots that object. The function can (optionally) first attempt to rotate the nodes of both trees to optimize vertical matching of tips.

0 comments on commit 7f96462

Please sign in to comment.