Browse code

geom_tiplab2 supports hjust

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

g.yu authored on 18/04/2016 11:27:05
Showing 3 changed files

... ...
@@ -1,5 +1,6 @@
1 1
 CHANGES IN VERSION 1.3.15
2 2
 ------------------------
3
+ o geom_tiplab2 supports parameter hjust <2016-04-18, Mon>
3 4
  o geom_tiplab and geom_tiplab2 support using geom_label2 by passing geom="label" <2016-04-07, Thu>
4 5
  o geom_label2 that support subsetting <2016-04-07, Thu>
5 6
  o geom_tiplab2 for adding tip label of circular layout <2016-04-06, Wed>
... ...
@@ -38,7 +38,7 @@ geom_tiplab <- function(mapping=NULL, hjust = 0, align = FALSE, linetype = "dott
38 38
     if (align && (!is.na(linetype) && !is.null(linetype))) {
39 39
         dot_mapping <- aes(xend=x+diff(range(x, na.rm=TRUE))/200, x=max(x, na.rm=TRUE), y=y, yend=y, subset=isTip)
40 40
         if (!is.null(mapping)) {
41
-            dot_mapping <- modifyList(dot_mapping, mapping)
41
+            dot_mapping <- modifyList(mapping, dot_mapping)
42 42
         }
43 43
     } 
44 44
     
... ...
@@ -63,12 +63,13 @@ geom_tiplab <- function(mapping=NULL, hjust = 0, align = FALSE, linetype = "dott
63 63
 ##' 
64 64
 ##' @title geom_tiplab2
65 65
 ##' @param mapping aes mapping
66
+##' @param hjust horizontal adjustment
66 67
 ##' @param ... additional parameter, see geom_tiplab
67 68
 ##' @return tip label layer
68 69
 ##' @export
69 70
 ##' @author Guangchuang Yu
70 71
 ##' @references \url{https://groups.google.com/forum/#!topic/bioc-ggtree/o35PV3iHO-0}
71
-geom_tiplab2 <- function(mapping=NULL, ...) {
72
+geom_tiplab2 <- function(mapping=NULL, hjust=0, ...) {
72 73
 
73 74
     angle <- NULL
74 75
     m1 <- aes(subset=(abs(angle) < 90), angle=angle)
... ...
@@ -79,7 +80,7 @@ geom_tiplab2 <- function(mapping=NULL, ...) {
79 80
         m2 <- modifyList(mapping, m2)
80 81
     }
81 82
 
82
-    list(geom_tiplab(m1, ...),
83
-         geom_tiplab(m2, hjust=1, ...)
83
+    list(geom_tiplab(m1, hjust=hjust, ...),
84
+         geom_tiplab(m2, hjust=1-hjust, ...)
84 85
          )
85 86
 }
... ...
@@ -4,11 +4,13 @@
4 4
 \alias{geom_tiplab2}
5 5
 \title{geom_tiplab2}
6 6
 \usage{
7
-geom_tiplab2(mapping = NULL, ...)
7
+geom_tiplab2(mapping = NULL, hjust = 0, ...)
8 8
 }
9 9
 \arguments{
10 10
 \item{mapping}{aes mapping}
11 11
 
12
+\item{hjust}{horizontal adjustment}
13
+
12 14
 \item{...}{additional parameter, see geom_tiplab}
13 15
 }
14 16
 \value{