Browse code

update add_legend

git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@107375 bc3139a8-67e5-0310-9ffc-ced21a209358

g.yu authored on 13/08/2015 12:46:02
Showing 2 changed files

  • NEWS index 28769b94..4c804beb 100644
  • R/ggtree.R index 743859f6..0ad1ab89 100644
... ...
@@ -1,5 +1,7 @@
1 1
 CHANGES IN VERSION 1.1.15
2 2
 ------------------------
3
+ o open text angle parameter for annotation_clade/annotation_clade2 <2015-08-13, Thu>
4
+ o support changing size of add_legend <2015-08-13, Thu>
3 5
  o reroot methods for phylo and beast <2015-08-07, Fri>
4 6
  
5 7
 CHANGES IN VERSION 1.1.14
... ...
@@ -440,7 +440,7 @@ flip <- function(tree_view, node1, node2) {
440 440
     anc <- getAncestor.df(df, node1)
441 441
     ii <- match(anc, df$node)
442 442
     df[ii, "y"] <- NA
443
-    currentNode <- as.vector(sapply(anc, getChild.df, df=df))
443
+    currentNode <- unlist(as.vector(sapply(anc, getChild.df, df=df)))
444 444
     currentNode <- currentNode[!currentNode %in% anc]
445 445
     
446 446
     tree_view$data <- re_assign_ycoord_df(df, currentNode)
... ...
@@ -677,7 +677,8 @@ add_legend <- function(p, x=NULL, y=NULL, offset=NULL, font.size=4, ...) {
677 677
         offset <- 0.4
678 678
     }
679 679
     p <- p + annotation_custom(linesGrob(), xmin=x, xmax=x+d, ymin=y, ymax=y) +
680
-        annotation_custom(textGrob(label=d), xmin=x+d/2, xmax=x+d/2, ymin=y+offset, ymax=y+offset)
680
+        annotation_custom(textGrob(label=d, gp = gpar(fontsize = font.size)),
681
+                          xmin=x+d/2, xmax=x+d/2, ymin=y+offset, ymax=y+offset)
681 682
     return(p)
682 683
 }
683 684
 
... ...
@@ -750,13 +751,13 @@ annotation_clade2 <- function(tree_view, tip1, tip2, label, bar.size=2, font.siz
750 751
 }
751 752
 
752 753
 
753
-annotation_clade_internal <- function(tree_view, x, y, label, bar.size, font.size, offset.text, ...) {
754
+annotation_clade_internal <- function(tree_view, x, y, label, bar.size, font.size, offset.text, angel=270, ...) {
754 755
     mx <- x
755 756
     if (is.null(offset.text)) {
756 757
         offset.text <- mx * 0.02
757 758
     }
758 759
     tree_view + geom_segment(x=mx, xend=mx, y=min(y), yend=max(y), size=bar.size, ...) +
759
-        annotate("text", label=label, x=mx+offset.text, y=mean(y), angle=270, size=font.size, ...)
760
+        annotate("text", label=label, x=mx+offset.text, y=mean(y), angle=angle, size=font.size, ...)
760 761
 }
761 762
 
762 763
 ##' @rdname groupOTU-methods