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
10 changes: 5 additions & 5 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ markChanges<-function(tree,colors=NULL,cex=1,lwd=2,plot=TRUE){
## function to label clades
## written by Liam J. Revell 2014, 2015
cladelabels<-function(tree=NULL,text,node,offset=NULL,wing.length=NULL,cex=1,
orientation="vertical"){
orientation="vertical",move=c(0,0),exp.c=0.7){
lastPP<-get("last_plot.phylo",envir=.PlotPhyloEnv)
if(is.null(tree)){
wing.length<-1
Expand All @@ -871,17 +871,17 @@ cladelabels<-function(tree=NULL,text,node,offset=NULL,wing.length=NULL,cex=1,
if(is.null(offset)) offset<-0.5
xx<-mapply(labelSubTree,node,text,
MoreArgs=list(tree=tree,pp=lastPP,offset=offset,wl=wing.length,cex=cex,
orientation=orientation))
orientation=orientation,move=move,exp.c=exp.c))
}

## internal function used by cladelabels
## written by Liam J. Revell 2014, 2015
labelSubTree<-function(tree,nn,label,pp,offset,wl,cex,orientation){
labelSubTree<-function(tree,nn,label,pp,offset,wl,cex,orientation,move,exp.c){
if(is.null(wl)) wl<-1
tree<-reorder(tree)
tips<-getDescendants(tree,nn)
tips<-tips[tips<=Ntip(tree)]
ec<-0.7 ## expansion constant
ec<-exp.c ## expansion constant
sw<-pp$cex*max(strwidth(tree$tip.label[tips]))
sh<-pp$cex*max(strheight(tree$tip.label))
cw<-mean(strwidth(LETTERS)*cex)
Expand All @@ -894,7 +894,7 @@ labelSubTree<-function(tree,nn,label,pp,offset,wl,cex,orientation){
c(y[1]-ec*sh,y[1]-ec*sh))
lines(c(h-wl*cw,h),
c(y[2]+ec*sh,y[2]+ec*sh))
text(h+cw,mean(y),
text(h+cw+move[1],mean(y)+move[2],
label,srt=if(orientation=="horizontal") 0 else 90,
adj=if(orientation=="horizontal") 0 else 0.5,cex=cex)
}
Expand Down
4 changes: 3 additions & 1 deletion man/cladelabels.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\title{Add labels to subtrees of a plotted phylogeny}
\usage{
cladelabels(tree=NULL, text, node, offset=NULL, wing.length=NULL, cex=1,
orientation="vertical")
orientation="vertical",move=c(0,0),exp.c=0.7)
arc.cladelabels(tree=NULL, text, node=NULL, ln.offset=1.02,
lab.offset=1.06, cex=1, orientation="curved",...)
}
Expand All @@ -16,6 +16,8 @@ arc.cladelabels(tree=NULL, text, node=NULL, ln.offset=1.02,
\item{wing.length}{length of the wings to add to the top & bottom of the label bar (in character widths).}
\item{cex}{character expansion factor.}
\item{orientation}{orientation of the text. Can be \code{orientation = "vertical"} (the default) or \code{"horizontal"}.}
\item{move}{horizontal and vertical adjustments}
\item{exp.c}{expansion constant}
\item{ln.offset}{line offset (as a function of total tree height) for \code{arc.cladelabels}.}
\item{lab.offset}{label offset for \code{arc.cladelabels}.}
\item{...}{optional arguments for \code{arc.cladelabels}.}
Expand Down