Browse code

remove rvcheck depend

xiangpin authored on 18/08/2021 06:27:37
Showing 1 changed files
... ...
@@ -20,7 +20,7 @@
20 20
 ##' @importFrom ggplot2 layer
21 21
 ##' @importFrom ggplot2 position_nudge
22 22
 ##' @importFrom ggplot2 aes_string
23
-##' @importFrom rvcheck get_aes_var
23
+##' @importFrom ggfun get_aes_var
24 24
 ##' @export
25 25
 ##' @seealso
26 26
 ##' [geom_text][ggplot2::geom_text]
Browse code

roxygen2md

Guangchuang Yu authored on 01/11/2019 04:24:00
Showing 1 changed files
... ...
@@ -23,7 +23,7 @@
23 23
 ##' @importFrom rvcheck get_aes_var
24 24
 ##' @export
25 25
 ##' @seealso
26
-##' \link[ggplot2]{geom_text}
26
+##' [geom_text][ggplot2::geom_text]
27 27
 ##' @author Guangchuang Yu
28 28
 geom_text2 <- function(mapping = NULL, data = NULL,
29 29
                        ...,
Browse code

geom_tiplab(parse="emoji") compatible with upcoming ggplot2 v=2.3.0

guangchuang yu authored on 23/05/2018 03:06:13
Showing 1 changed files
... ...
@@ -20,6 +20,7 @@
20 20
 ##' @importFrom ggplot2 layer
21 21
 ##' @importFrom ggplot2 position_nudge
22 22
 ##' @importFrom ggplot2 aes_string
23
+##' @importFrom rvcheck get_aes_var
23 24
 ##' @export
24 25
 ##' @seealso
25 26
 ##' \link[ggplot2]{geom_text}
... ...
@@ -53,11 +54,13 @@ geom_text2 <- function(mapping = NULL, data = NULL,
53 54
     }
54 55
 
55 56
     if (parse == "emoji") {
56
-        label_aes <- aes_string(label=paste0("suppressMessages(emoji(", as.list(mapping)$label,"))"))
57
-        mapping <- modifyList(mapping, label_aes)
58 57
         emoji <- get_fun_from_pkg("emojifont", "emoji")
59 58
         parse <- FALSE
60 59
         family <- "EmojiOne"
60
+        ## label_aes <- aes_string(label=paste0("suppressMessages(emoji(", as.list(mapping)$label,"))"))
61
+        label_aes <- aes_string(label=paste0("suppressMessages(emoji(", get_aes_var(mapping, "label"), "))"))
62
+        ## mapping <- modifyList(mapping, aes(label=emoji(!!mapping$label))) ## ggplot2 >= 2.3.0
63
+        mapping <- modifyList(mapping, label_aes)
61 64
     }
62 65
 
63 66
     layer(
Browse code

now geom_text2, geom_label2, geom_point2 and geom_segment2 work with ggplot2

guangchuang yu authored on 01/08/2017 12:22:46
Showing 1 changed files
... ...
@@ -6,6 +6,7 @@
6 6
 ##' @param data A layer specific dataset -
7 7
 ##'             only needed if you want to override he plot defaults.
8 8
 ##' @param ... other arguments passed on to 'layer'
9
+##' @param stat Name of stat to modify data
9 10
 ##' @param position The position adjustment to use for overlapping points on this layer
10 11
 ##' @param family sans by default, can be any supported font
11 12
 ##' @param parse if TRUE, the labels will be passd into expressions
... ...
@@ -25,6 +26,7 @@
25 26
 ##' @author Guangchuang Yu
26 27
 geom_text2 <- function(mapping = NULL, data = NULL,
27 28
                        ...,
29
+                       stat = "identity",
28 30
                        position = "identity",
29 31
                        family="sans",
30 32
                        parse = FALSE,
... ...
@@ -43,7 +45,7 @@ geom_text2 <- function(mapping = NULL, data = NULL,
43 45
         position <- position_nudge(nudge_x, nudge_y)
44 46
     }
45 47
 
46
-    default_aes <- aes_(node=~node)
48
+    default_aes <- aes_() #node=~node)
47 49
     if (is.null(mapping)) {
48 50
         mapping <- default_aes
49 51
     } else {
... ...
@@ -61,7 +63,7 @@ geom_text2 <- function(mapping = NULL, data = NULL,
61 63
     layer(
62 64
         data = data,
63 65
         mapping = mapping,
64
-        stat = StatTreeData,
66
+        stat = stat, #StatTreeData,
65 67
         geom = GeomTextGGtree,
66 68
         position = position,
67 69
         show.legend = show.legend,
... ...
@@ -94,7 +96,7 @@ GeomTextGGtree <- ggproto("GeomTextGGtree", GeomText,
94 96
                               GeomText$draw_panel(data, panel_scales, coord, parse,
95 97
                                                   na.rm, check_overlap)
96 98
                           },
97
-                          required_aes = c("node", "x", "y", "label"),
99
+                          required_aes = c("x", "y", "label"),
98 100
 
99 101
                           default_aes = aes(colour = "black", size = 3.88, angle = 0, hjust = 0.5,
100 102
                               vjust = 0.5, alpha = NA, family = "", fontface = 1, lineheight = 1.2),
Browse code

fixed #115

guangchuang yu authored on 02/03/2017 02:49:53
Showing 1 changed files
... ...
@@ -5,13 +5,13 @@
5 5
 ##' @param mapping the aesthetic mapping
6 6
 ##' @param data A layer specific dataset -
7 7
 ##'             only needed if you want to override he plot defaults.
8
+##' @param ... other arguments passed on to 'layer'
8 9
 ##' @param position The position adjustment to use for overlapping points on this layer
9 10
 ##' @param family sans by default, can be any supported font
10 11
 ##' @param parse if TRUE, the labels will be passd into expressions
11 12
 ##' @param na.rm logical
12 13
 ##' @param show.legend logical
13 14
 ##' @param inherit.aes logical
14
-##' @param ... other arguments passed on to 'layer'
15 15
 ##' @param nudge_x horizontal adjustment
16 16
 ##' @param nudge_y vertical adjustment
17 17
 ##' @param check_overlap if TRUE, text that overlaps previous text in the same layer will not be plotted
... ...
@@ -24,9 +24,16 @@
24 24
 ##' \link[ggplot2]{geom_text}
25 25
 ##' @author Guangchuang Yu
26 26
 geom_text2 <- function(mapping = NULL, data = NULL,
27
-                       position = "identity", family="sans", parse = FALSE,
28
-                       na.rm=TRUE, show.legend = NA, inherit.aes = TRUE,
29
-                       ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE) {
27
+                       ...,
28
+                       position = "identity",
29
+                       family="sans",
30
+                       parse = FALSE,
31
+                       na.rm=TRUE,
32
+                       show.legend = NA,
33
+                       inherit.aes = TRUE,
34
+                       nudge_x = 0,
35
+                       nudge_y = 0,
36
+                       check_overlap = FALSE) {
30 37
 
31 38
     if (!missing(nudge_x) || !missing(nudge_y)) {
32 39
         if (!missing(position)) {
Browse code

use EmojiOne font

guangchuang yu authored on 17/02/2017 05:00:22
Showing 1 changed files
... ...
@@ -48,7 +48,7 @@ geom_text2 <- function(mapping = NULL, data = NULL,
48 48
         mapping <- modifyList(mapping, label_aes)
49 49
         emoji <- get_fun_from_pkg("emojifont", "emoji")
50 50
         parse <- FALSE
51
-        family <- "OpenSansEmoji"
51
+        family <- "EmojiOne"
52 52
     }
53 53
 
54 54
     layer(
Browse code

parse="emoji" :)

guangchuang yu authored on 16/02/2017 06:54:38
Showing 1 changed files
... ...
@@ -6,6 +6,7 @@
6 6
 ##' @param data A layer specific dataset -
7 7
 ##'             only needed if you want to override he plot defaults.
8 8
 ##' @param position The position adjustment to use for overlapping points on this layer
9
+##' @param family sans by default, can be any supported font
9 10
 ##' @param parse if TRUE, the labels will be passd into expressions
10 11
 ##' @param na.rm logical
11 12
 ##' @param show.legend logical
... ...
@@ -17,13 +18,14 @@
17 18
 ##' @return text layer
18 19
 ##' @importFrom ggplot2 layer
19 20
 ##' @importFrom ggplot2 position_nudge
21
+##' @importFrom ggplot2 aes_string
20 22
 ##' @export
21 23
 ##' @seealso
22 24
 ##' \link[ggplot2]{geom_text}
23 25
 ##' @author Guangchuang Yu
24 26
 geom_text2 <- function(mapping = NULL, data = NULL,
25
-                       position = "identity", parse = FALSE, na.rm=TRUE, show.legend = NA,
26
-                       inherit.aes = TRUE,
27
+                       position = "identity", family="sans", parse = FALSE,
28
+                       na.rm=TRUE, show.legend = NA, inherit.aes = TRUE,
27 29
                        ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE) {
28 30
 
29 31
     if (!missing(nudge_x) || !missing(nudge_y)) {
... ...
@@ -41,6 +43,14 @@ geom_text2 <- function(mapping = NULL, data = NULL,
41 43
         mapping <- modifyList(mapping, default_aes)
42 44
     }
43 45
 
46
+    if (parse == "emoji") {
47
+        label_aes <- aes_string(label=paste0("suppressMessages(emoji(", as.list(mapping)$label,"))"))
48
+        mapping <- modifyList(mapping, label_aes)
49
+        emoji <- get_fun_from_pkg("emojifont", "emoji")
50
+        parse <- FALSE
51
+        family <- "OpenSansEmoji"
52
+    }
53
+
44 54
     layer(
45 55
         data = data,
46 56
         mapping = mapping,
... ...
@@ -50,10 +60,11 @@ geom_text2 <- function(mapping = NULL, data = NULL,
50 60
         show.legend = show.legend,
51 61
         inherit.aes = inherit.aes,
52 62
         params = list(
53
-          parse = parse,
54
-          check_overlap = check_overlap,
55
-          na.rm = na.rm,
56
-          ...
63
+            parse = parse,
64
+            family = family,
65
+            check_overlap = check_overlap,
66
+            na.rm = na.rm,
67
+            ...
57 68
         ),
58 69
         check.aes = FALSE
59 70
     )
Browse code

subset supports logical vector contains NA, and geom_cladelabel supports parsing emoji

guangchuang yu authored on 16/02/2017 06:10:17
Showing 1 changed files
... ...
@@ -66,7 +66,7 @@ GeomTextGGtree <- ggproto("GeomTextGGtree", GeomText,
66 66
                           setup_data = function(data, params) {
67 67
                               if (is.null(data$subset))
68 68
                                   return(data)
69
-                              data[data$subset,]
69
+                              data[which(data$subset),] ## use `which` makes it compatible with NA
70 70
                           },
71 71
                           ## compute_group = function(data, params) {
72 72
                           ##     data
Browse code

ggplot2 2.2.0

guangchuang yu authored on 14/11/2016 04:41:23
Showing 1 changed files
... ...
@@ -55,7 +55,7 @@ geom_text2 <- function(mapping = NULL, data = NULL,
55 55
           na.rm = na.rm,
56 56
           ...
57 57
         ),
58
-        if (packageVersion('ggplot2') > '2.1.0') check.aes = FALSE
58
+        check.aes = FALSE
59 59
     )
60 60
 }
61 61
 
Browse code

fixed R check

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

g.yu authored on 11/10/2016 01:31:56
Showing 1 changed files
... ...
@@ -55,7 +55,7 @@ geom_text2 <- function(mapping = NULL, data = NULL,
55 55
           na.rm = na.rm,
56 56
           ...
57 57
         ),
58
-        check.aes = FALSE
58
+        if (packageVersion('ggplot2') > '2.1.0') check.aes = FALSE
59 59
     )
60 60
 }
61 61
 
Browse code

version 1.5.15

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

g.yu authored on 07/10/2016 05:18:29
Showing 1 changed files
... ...
@@ -22,7 +22,8 @@
22 22
 ##' \link[ggplot2]{geom_text}
23 23
 ##' @author Guangchuang Yu
24 24
 geom_text2 <- function(mapping = NULL, data = NULL,
25
-                       position = "identity", parse = FALSE, na.rm=TRUE, show.legend = NA, inherit.aes = TRUE,
25
+                       position = "identity", parse = FALSE, na.rm=TRUE, show.legend = NA,
26
+                       inherit.aes = TRUE,
26 27
                        ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE) {
27 28
 
28 29
     if (!missing(nudge_x) || !missing(nudge_y)) {
... ...
@@ -53,7 +54,8 @@ geom_text2 <- function(mapping = NULL, data = NULL,
53 54
           check_overlap = check_overlap,
54 55
           na.rm = na.rm,
55 56
           ...
56
-        )
57
+        ),
58
+        check.aes = FALSE
57 59
     )
58 60
 }
59 61
 
Browse code

add `compute_group` according to ggplot (v2.1.0) <2016-09-29, Thu>

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

g.yu authored on 29/09/2016 05:55:59
Showing 1 changed files
... ...
@@ -1,6 +1,6 @@
1 1
 ##' geom_text2 support aes(subset) via setup_data
2 2
 ##'
3
-##' 
3
+##'
4 4
 ##' @title geom_text2
5 5
 ##' @param mapping the aesthetic mapping
6 6
 ##' @param data A layer specific dataset -
... ...
@@ -29,17 +29,17 @@ geom_text2 <- function(mapping = NULL, data = NULL,
29 29
         if (!missing(position)) {
30 30
             stop("Specify either `position` or `nudge_x`/`nudge_y`", call. = FALSE)
31 31
         }
32
-        
32
+
33 33
         position <- position_nudge(nudge_x, nudge_y)
34 34
     }
35
-    
35
+
36 36
     default_aes <- aes_(node=~node)
37 37
     if (is.null(mapping)) {
38 38
         mapping <- default_aes
39 39
     } else {
40 40
         mapping <- modifyList(mapping, default_aes)
41 41
     }
42
-    
42
+
43 43
     layer(
44 44
         data = data,
45 45
         mapping = mapping,
... ...
@@ -66,16 +66,19 @@ GeomTextGGtree <- ggproto("GeomTextGGtree", GeomText,
66 66
                                   return(data)
67 67
                               data[data$subset,]
68 68
                           },
69
+                          ## compute_group = function(data, params) {
70
+                          ##     data
71
+                          ## },
69 72
                           draw_panel = function(data, panel_scales, coord, parse = FALSE,
70 73
                               na.rm = TRUE, check_overlap = FALSE) {
71 74
                               GeomText$draw_panel(data, panel_scales, coord, parse,
72 75
                                                   na.rm, check_overlap)
73 76
                           },
74 77
                           required_aes = c("node", "x", "y", "label"),
75
-                          
78
+
76 79
                           default_aes = aes(colour = "black", size = 3.88, angle = 0, hjust = 0.5,
77 80
                               vjust = 0.5, alpha = NA, family = "", fontface = 1, lineheight = 1.2),
78
-                          
81
+
79 82
                           draw_key = draw_key_text
80 83
                           )
81 84
 
Browse code

geom_label2

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

g.yu authored on 07/04/2016 04:02:44
Showing 1 changed files
... ...
@@ -5,7 +5,6 @@
5 5
 ##' @param mapping the aesthetic mapping
6 6
 ##' @param data A layer specific dataset -
7 7
 ##'             only needed if you want to override he plot defaults.
8
-##' @param stat The statistical transformation to use on the data for this layer
9 8
 ##' @param position The position adjustment to use for overlapping points on this layer
10 9
 ##' @param parse if TRUE, the labels will be passd into expressions
11 10
 ##' @param na.rm logical
... ...
@@ -22,7 +21,7 @@
22 21
 ##' @seealso
23 22
 ##' \link[ggplot2]{geom_text}
24 23
 ##' @author Guangchuang Yu
25
-geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
24
+geom_text2 <- function(mapping = NULL, data = NULL,
26 25
                        position = "identity", parse = FALSE, na.rm=TRUE, show.legend = NA, inherit.aes = TRUE,
27 26
                        ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE) {
28 27
 
... ...
@@ -44,7 +43,7 @@ geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
44 43
     layer(
45 44
         data = data,
46 45
         mapping = mapping,
47
-        stat = StatTreeLabel,
46
+        stat = StatTreeData,
48 47
         geom = GeomTextGGtree,
49 48
         position = position,
50 49
         show.legend = show.legend,
... ...
@@ -80,11 +79,11 @@ GeomTextGGtree <- ggproto("GeomTextGGtree", GeomText,
80 79
                           draw_key = draw_key_text
81 80
                           )
82 81
 
83
-StatTreeLabel <-  ggproto("StatTreeLabel", Stat,
84
-                          required_aes = "node",
85
-                          compute_group = function(data, scales) {
86
-                              setup_tree_data(data)
87
-                          }
88
-                          )
82
+StatTreeData <-  ggproto("StatTreeLabel", Stat,
83
+                         required_aes = "node",
84
+                         compute_group = function(data, scales) {
85
+                             setup_tree_data(data)
86
+                         }
87
+                         )
89 88
 
90 89
 
Browse code

new features

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

g.yu authored on 16/02/2016 04:04:44
Showing 1 changed files
... ...
@@ -2,46 +2,6 @@
2 2
 ##'
3 3
 ##' 
4 4
 ##' @title geom_text2
5
-##' @inheritParams geom_text
6
-##' @return text layer
7
-##' @importFrom ggplot2 layer
8
-##' @importFrom ggplot2 position_nudge
9
-##' @export
10
-##' @seealso
11
-##' \link[ggplot2]{geom_text}
12
-##' @author Guangchuang Yu
13
-geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
14
-  position = "identity", parse = FALSE, na.rm=TRUE, show.legend = NA, inherit.aes = TRUE,
15
-  ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE)
16
-{
17
-  if (!missing(nudge_x) || !missing(nudge_y)) {
18
-    if (!missing(position)) {
19
-      stop("Specify either `position` or `nudge_x`/`nudge_y`", call. = FALSE)
20
-    }
21
-
22
-    position <- position_nudge(nudge_x, nudge_y)
23
-  }
24
-
25
-  layer(
26
-      data = data,
27
-      mapping = mapping,
28
-      stat = stat,
29
-      geom = GeomTextGGtree,
30
-      position = position,
31
-      show.legend = show.legend,
32
-      inherit.aes = inherit.aes,
33
-      params = list(
34
-          parse = parse,
35
-          check_overlap = check_overlap,
36
-          na.rm = na.rm,
37
-          ...
38
-          )
39
-      )
40
-}
41
-
42
-##' text annotations
43
-##' @export
44
-##' @rdname geom_text
45 5
 ##' @param mapping the aesthetic mapping
46 6
 ##' @param data A layer specific dataset -
47 7
 ##'             only needed if you want to override he plot defaults.
... ...
@@ -55,33 +15,76 @@ geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
55 15
 ##' @param nudge_x horizontal adjustment
56 16
 ##' @param nudge_y vertical adjustment
57 17
 ##' @param check_overlap if TRUE, text that overlaps previous text in the same layer will not be plotted
58
-##' @source
59
-##' This is just the imported function
60
-##' from the ggplot2 package. The documentation you should
61
-##' read for the geom_text function can be found here: \link[ggplot2]{geom_text}
62
-##'
18
+##' @return text layer
19
+##' @importFrom ggplot2 layer
20
+##' @importFrom ggplot2 position_nudge
21
+##' @export
63 22
 ##' @seealso
64 23
 ##' \link[ggplot2]{geom_text}
65
-geom_text <- ggplot2::geom_text
24
+##' @author Guangchuang Yu
25
+geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
26
+                       position = "identity", parse = FALSE, na.rm=TRUE, show.legend = NA, inherit.aes = TRUE,
27
+                       ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE) {
28
+
29
+    if (!missing(nudge_x) || !missing(nudge_y)) {
30
+        if (!missing(position)) {
31
+            stop("Specify either `position` or `nudge_x`/`nudge_y`", call. = FALSE)
32
+        }
33
+        
34
+        position <- position_nudge(nudge_x, nudge_y)
35
+    }
36
+    
37
+    default_aes <- aes_(node=~node)
38
+    if (is.null(mapping)) {
39
+        mapping <- default_aes
40
+    } else {
41
+        mapping <- modifyList(mapping, default_aes)
42
+    }
43
+    
44
+    layer(
45
+        data = data,
46
+        mapping = mapping,
47
+        stat = StatTreeLabel,
48
+        geom = GeomTextGGtree,
49
+        position = position,
50
+        show.legend = show.legend,
51
+        inherit.aes = inherit.aes,
52
+        params = list(
53
+          parse = parse,
54
+          check_overlap = check_overlap,
55
+          na.rm = na.rm,
56
+          ...
57
+        )
58
+    )
59
+}
66 60
 
67 61
 
68 62
 ##' @importFrom ggplot2 GeomText
69 63
 ##' @importFrom ggplot2 draw_key_text
70 64
 GeomTextGGtree <- ggproto("GeomTextGGtree", GeomText,
71 65
                           setup_data = function(data, params) {
66
+                              if (is.null(data$subset))
67
+                                  return(data)
72 68
                               data[data$subset,]
73 69
                           },
74
-                          
75 70
                           draw_panel = function(data, panel_scales, coord, parse = FALSE,
76
-                              na.rm = FALSE, check_overlap = FALSE) {
71
+                              na.rm = TRUE, check_overlap = FALSE) {
77 72
                               GeomText$draw_panel(data, panel_scales, coord, parse,
78 73
                                                   na.rm, check_overlap)
79 74
                           },
80
-
81
-                          required_aes = c("x", "y", "label"),
75
+                          required_aes = c("node", "x", "y", "label"),
82 76
                           
83 77
                           default_aes = aes(colour = "black", size = 3.88, angle = 0, hjust = 0.5,
84 78
                               vjust = 0.5, alpha = NA, family = "", fontface = 1, lineheight = 1.2),
85 79
                           
86 80
                           draw_key = draw_key_text
87 81
                           )
82
+
83
+StatTreeLabel <-  ggproto("StatTreeLabel", Stat,
84
+                          required_aes = "node",
85
+                          compute_group = function(data, scales) {
86
+                              setup_tree_data(data)
87
+                          }
88
+                          )
89
+
90
+
Browse code

lots updates

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

g.yu authored on 22/12/2015 04:08:02
Showing 1 changed files
... ...
@@ -1,3 +1,43 @@
1
+##' geom_text2 support aes(subset) via setup_data
2
+##'
3
+##' 
4
+##' @title geom_text2
5
+##' @inheritParams geom_text
6
+##' @return text layer
7
+##' @importFrom ggplot2 layer
8
+##' @importFrom ggplot2 position_nudge
9
+##' @export
10
+##' @seealso
11
+##' \link[ggplot2]{geom_text}
12
+##' @author Guangchuang Yu
13
+geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
14
+  position = "identity", parse = FALSE, na.rm=TRUE, show.legend = NA, inherit.aes = TRUE,
15
+  ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE)
16
+{
17
+  if (!missing(nudge_x) || !missing(nudge_y)) {
18
+    if (!missing(position)) {
19
+      stop("Specify either `position` or `nudge_x`/`nudge_y`", call. = FALSE)
20
+    }
21
+
22
+    position <- position_nudge(nudge_x, nudge_y)
23
+  }
24
+
25
+  layer(
26
+      data = data,
27
+      mapping = mapping,
28
+      stat = stat,
29
+      geom = GeomTextGGtree,
30
+      position = position,
31
+      show.legend = show.legend,
32
+      inherit.aes = inherit.aes,
33
+      params = list(
34
+          parse = parse,
35
+          check_overlap = check_overlap,
36
+          na.rm = na.rm,
37
+          ...
38
+          )
39
+      )
40
+}
1 41
 
2 42
 ##' text annotations
3 43
 ##' @export
... ...
@@ -8,7 +48,13 @@
8 48
 ##' @param stat The statistical transformation to use on the data for this layer
9 49
 ##' @param position The position adjustment to use for overlapping points on this layer
10 50
 ##' @param parse if TRUE, the labels will be passd into expressions
51
+##' @param na.rm logical
52
+##' @param show.legend logical
53
+##' @param inherit.aes logical
11 54
 ##' @param ... other arguments passed on to 'layer'
55
+##' @param nudge_x horizontal adjustment
56
+##' @param nudge_y vertical adjustment
57
+##' @param check_overlap if TRUE, text that overlaps previous text in the same layer will not be plotted
12 58
 ##' @source
13 59
 ##' This is just the imported function
14 60
 ##' from the ggplot2 package. The documentation you should
... ...
@@ -18,3 +64,24 @@
18 64
 ##' \link[ggplot2]{geom_text}
19 65
 geom_text <- ggplot2::geom_text
20 66
 
67
+
68
+##' @importFrom ggplot2 GeomText
69
+##' @importFrom ggplot2 draw_key_text
70
+GeomTextGGtree <- ggproto("GeomTextGGtree", GeomText,
71
+                          setup_data = function(data, params) {
72
+                              data[data$subset,]
73
+                          },
74
+                          
75
+                          draw_panel = function(data, panel_scales, coord, parse = FALSE,
76
+                              na.rm = FALSE, check_overlap = FALSE) {
77
+                              GeomText$draw_panel(data, panel_scales, coord, parse,
78
+                                                  na.rm, check_overlap)
79
+                          },
80
+
81
+                          required_aes = c("x", "y", "label"),
82
+                          
83
+                          default_aes = aes(colour = "black", size = 3.88, angle = 0, hjust = 0.5,
84
+                              vjust = 0.5, alpha = NA, family = "", fontface = 1, lineheight = 1.2),
85
+                          
86
+                          draw_key = draw_key_text
87
+                          )
Browse code

revert to previous version for compatible with CRAN version of ggplot2

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

g.yu authored on 31/08/2015 03:34:32
Showing 1 changed files
... ...
@@ -1,42 +1,3 @@
1
-##' geom_text2 support aes(subset) via setup_data
2
-##'
3
-##' 
4
-##' @title geom_text2
5
-##' @inheritParams geom_text
6
-##' @return text layer
7
-##' @importFrom ggplot2 layer
8
-##' @importFrom ggplot2 position_nudge
9
-##' @export
10
-##' @seealso
11
-##' \link[ggplot2]{geom_text}
12
-##' @author Guangchuang Yu
13
-geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
14
-  position = "identity", parse = FALSE, show.legend = NA, inherit.aes = TRUE,
15
-  ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE)
16
-{
17
-  if (!missing(nudge_x) || !missing(nudge_y)) {
18
-    if (!missing(position)) {
19
-      stop("Specify either `position` or `nudge_x`/`nudge_y`", call. = FALSE)
20
-    }
21
-
22
-    position <- position_nudge(nudge_x, nudge_y)
23
-  }
24
-
25
-  layer(
26
-    data = data,
27
-    mapping = mapping,
28
-    stat = stat,
29
-    geom = GeomTextGGtree,
30
-    position = position,
31
-    show.legend = show.legend,
32
-    inherit.aes = inherit.aes,
33
-    params = list(
34
-      parse = parse,
35
-      check_overlap = check_overlap,
36
-      ...
37
-    )
38
-  )
39
-}
40 1
 
41 2
 ##' text annotations
42 3
 ##' @export
... ...
@@ -47,12 +8,7 @@ geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
47 8
 ##' @param stat The statistical transformation to use on the data for this layer
48 9
 ##' @param position The position adjustment to use for overlapping points on this layer
49 10
 ##' @param parse if TRUE, the labels will be passd into expressions
50
-##' @param show.legend logical
51
-##' @param inherit.aes logical
52 11
 ##' @param ... other arguments passed on to 'layer'
53
-##' @param nudge_x horizontal adjustment
54
-##' @param nudge_y vertical adjustment
55
-##' @param check_overlap if TRUE, text that overlaps previous text in the same layer will not be plotted
56 12
 ##' @source
57 13
 ##' This is just the imported function
58 14
 ##' from the ggplot2 package. The documentation you should
... ...
@@ -62,24 +18,3 @@ geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
62 18
 ##' \link[ggplot2]{geom_text}
63 19
 geom_text <- ggplot2::geom_text
64 20
 
65
-
66
-##' @importFrom ggplot2 GeomText
67
-##' @importFrom ggplot2 draw_key_text
68
-GeomTextGGtree <- ggproto("GeomTextGGtree", GeomText,
69
-                          setup_data = function(data, params) {
70
-                              data[data$subset,]
71
-                          },
72
-                          
73
-                          draw_panel = function(data, panel_scales, coord, parse = FALSE,
74
-                              na.rm = FALSE, check_overlap = FALSE) {
75
-                              GeomText$draw_panel(data, panel_scales, coord, parse,
76
-                                                  na.rm, check_overlap)
77
-                          },
78
-
79
-                          required_aes = c("x", "y", "label"),
80
-                          
81
-                          default_aes = aes(colour = "black", size = 3.88, angle = 0, hjust = 0.5,
82
-                              vjust = 0.5, alpha = NA, family = "", fontface = 1, lineheight = 1.2),
83
-                          
84
-                          draw_key = draw_key_text
85
-                          )
Browse code

update according to changes of ggplot2

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

g.yu authored on 28/08/2015 13:39:22
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,85 @@
1
+##' geom_text2 support aes(subset) via setup_data
2
+##'
3
+##' 
4
+##' @title geom_text2
5
+##' @inheritParams geom_text
6
+##' @return text layer
7
+##' @importFrom ggplot2 layer
8
+##' @importFrom ggplot2 position_nudge
9
+##' @export
10
+##' @seealso
11
+##' \link[ggplot2]{geom_text}
12
+##' @author Guangchuang Yu
13
+geom_text2 <- function(mapping = NULL, data = NULL, stat = "identity",
14
+  position = "identity", parse = FALSE, show.legend = NA, inherit.aes = TRUE,
15
+  ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE)
16
+{
17
+  if (!missing(nudge_x) || !missing(nudge_y)) {
18
+    if (!missing(position)) {
19
+      stop("Specify either `position` or `nudge_x`/`nudge_y`", call. = FALSE)
20
+    }
21
+
22
+    position <- position_nudge(nudge_x, nudge_y)
23
+  }
24
+
25
+  layer(
26
+    data = data,
27
+    mapping = mapping,
28
+    stat = stat,
29
+    geom = GeomTextGGtree,
30
+    position = position,
31
+    show.legend = show.legend,
32
+    inherit.aes = inherit.aes,
33
+    params = list(
34
+      parse = parse,
35
+      check_overlap = check_overlap,
36
+      ...
37
+    )
38
+  )
39
+}
40
+
41
+##' text annotations
42
+##' @export
43
+##' @rdname geom_text
44
+##' @param mapping the aesthetic mapping
45
+##' @param data A layer specific dataset -
46
+##'             only needed if you want to override he plot defaults.
47
+##' @param stat The statistical transformation to use on the data for this layer
48
+##' @param position The position adjustment to use for overlapping points on this layer
49
+##' @param parse if TRUE, the labels will be passd into expressions
50
+##' @param show.legend logical
51
+##' @param inherit.aes logical
52
+##' @param ... other arguments passed on to 'layer'
53
+##' @param nudge_x horizontal adjustment
54
+##' @param nudge_y vertical adjustment
55
+##' @param check_overlap if TRUE, text that overlaps previous text in the same layer will not be plotted
56
+##' @source
57
+##' This is just the imported function
58
+##' from the ggplot2 package. The documentation you should
59
+##' read for the geom_text function can be found here: \link[ggplot2]{geom_text}
60
+##'
61
+##' @seealso
62
+##' \link[ggplot2]{geom_text}
63
+geom_text <- ggplot2::geom_text
64
+
65
+
66
+##' @importFrom ggplot2 GeomText
67
+##' @importFrom ggplot2 draw_key_text
68
+GeomTextGGtree <- ggproto("GeomTextGGtree", GeomText,
69
+                          setup_data = function(data, params) {
70
+                              data[data$subset,]
71
+                          },
72
+                          
73
+                          draw_panel = function(data, panel_scales, coord, parse = FALSE,
74
+                              na.rm = FALSE, check_overlap = FALSE) {
75
+                              GeomText$draw_panel(data, panel_scales, coord, parse,
76
+                                                  na.rm, check_overlap)
77
+                          },
78
+
79
+                          required_aes = c("x", "y", "label"),
80
+                          
81
+                          default_aes = aes(colour = "black", size = 3.88, angle = 0, hjust = 0.5,
82
+                              vjust = 0.5, alpha = NA, family = "", fontface = 1, lineheight = 1.2),
83
+                          
84
+                          draw_key = draw_key_text
85
+                          )