Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions R/plotTree.wBars.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ plotTree.barplot<-function(tree,x,args.plotTree=list(),
## written by Liam J. Revell 2014, 2015, 2018, 2019

plotTree.wBars<-function(tree,x,scale=NULL,width=NULL,type="phylogram",
method="plotTree",tip.labels=FALSE,col="grey",border=NULL,...){
method="plotTree",tip.labels=FALSE,col="grey",border="black",...){
if(!inherits(tree,"phylo")) stop("tree should be an object of class \"phylo\".")
if(is.null(scale)){
scale<-0.3*max(nodeHeights(tree))/diff(range(x))
Expand Down Expand Up @@ -201,6 +201,9 @@ plotTree.wBars<-function(tree,x,scale=NULL,width=NULL,type="phylogram",
if(length(col)<Ntip(tree)) col<-rep(col,ceiling(Ntip(tree)/length(col)))[1:Ntip(tree)]
if(is.null(names(col))) names(col)<-tree$tip.label
col<-col[tree$tip.label]
if(length(border)<Ntip(tree)) border<-rep(border,ceiling(Ntip(tree)/length(border)))[1:Ntip(tree)]
if(is.null(names(border))) names(border)<-tree$tip.label
border<-border[tree$tip.label]
if(type=="phylogram"){
if(hasArg(direction)) direction<-list(...)$direction
else direction<-"rightwards"
Expand All @@ -213,7 +216,7 @@ plotTree.wBars<-function(tree,x,scale=NULL,width=NULL,type="phylogram",
y1<-y4<-dy-w/2
y2<-y3<-dy+w/2
polygon(c(x1,x2,x3,x4)-min(0,min(x)),
c(y1,y2,y3,y4),col=col[i],border=border)
c(y1,y2,y3,y4),col=col[i],border=border[i])
}
} else if(type=="fan"){
h<-max(nodeHeights(tree))
Expand All @@ -232,7 +235,7 @@ plotTree.wBars<-function(tree,x,scale=NULL,width=NULL,type="phylogram",
x4<-s*x[i]*cos(theta)+x1
y4<-s*x[i]*sin(theta)+y1
polygon(c(x1,x2,x3,x4),c(y1,y2,y3,y4),col=col[i],
border=border)
border=border[i])
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion man/plotTree.wBars.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plotTree.boxplot(tree, x, args.plotTree=list(), args.boxplot=list())
\item{method}{plotting method to use. Can be \code{"plotTree"} (for \code{\link{plotTree}}) or \code{"plotSimmap"} (for \code{\link{plotSimmap}}).}
\item{tip.labels}{argument indicating whether or not tip labels should be plotted. Defaults to \code{tip.labels=FALSE}.}
\item{col}{colors of the plotted bars. Can be a single value or a vector with length equal to the number of tips in the tree.}
\item{border}{single value specifying the color of the border for the plotted bars. Defaults to \code{border=NULL}, which means that black borders will be plotted.}
\item{border}{colors of the borders of the plotted bars. Can be a single value or a vector with length equal to the number of tips in the tree.}
\item{args.plotTree}{in \code{plotTree.barplot}, arguments to be passed to \code{\link{plotTree}}.}
\item{args.barplot}{in \code{plotTree.barplot}, arguments to be passed to \code{\link{barplot}}.}
\item{args.boxplot}{in \code{plotTree.boxplot}, arguments to be passed to \code{\link{boxplot}}.}
Expand Down