... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
CHANGES IN VERSION 1.7.7 |
2 | 2 |
------------------------ |
3 |
- o geom_cladelabel support parse="emoji" <2017-02-16, Thu> |
|
3 |
+ o supports parse="emoji" in geom_cladelabel, geom_text2, geom_label2, geom_tiplab, geom_tiplab2 <2017-02-16, Thu> |
|
4 | 4 |
o aes(subset) now support logical vector contains NA <2017-02-16, Thu> |
5 | 5 |
o add legend transparency to theme_transparent <2017-02-13, Mon> |
6 | 6 |
+ <https://github.com/GuangchuangYu/ggtree/pull/112> |
... | ... |
@@ -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 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 nudge_x horizontal adjustment |
11 | 12 |
##' @param nudge_y vertical adjustment |
... | ... |
@@ -24,6 +25,7 @@ |
24 | 25 |
##' @author Guangchuang Yu |
25 | 26 |
geom_label2 <- function(mapping = NULL, data = NULL, |
26 | 27 |
..., |
28 |
+ family = "sans", |
|
27 | 29 |
parse = FALSE, |
28 | 30 |
nudge_x = 0, |
29 | 31 |
nudge_y = 0, |
... | ... |
@@ -51,6 +53,15 @@ geom_label2 <- function(mapping = NULL, data = NULL, |
51 | 53 |
mapping <- modifyList(mapping, default_aes) |
52 | 54 |
} |
53 | 55 |
|
56 |
+ if (parse == "emoji") { |
|
57 |
+ label_aes <- aes_string(label=paste0("suppressMessages(emoji(", as.list(mapping)$label,"))")) |
|
58 |
+ mapping <- modifyList(mapping, label_aes) |
|
59 |
+ emoji <- get_fun_from_pkg("emojifont", "emoji") |
|
60 |
+ parse <- FALSE |
|
61 |
+ family <- "OpenSansEmoji" |
|
62 |
+ } |
|
63 |
+ |
|
64 |
+ |
|
54 | 65 |
layer( |
55 | 66 |
data = data, |
56 | 67 |
mapping = mapping, |
... | ... |
@@ -61,6 +72,7 @@ geom_label2 <- function(mapping = NULL, data = NULL, |
61 | 72 |
inherit.aes = inherit.aes, |
62 | 73 |
params = list( |
63 | 74 |
parse = parse, |
75 |
+ family = family, |
|
64 | 76 |
label.padding = label.padding, |
65 | 77 |
label.r = label.r, |
66 | 78 |
label.size = label.size, |
... | ... |
@@ -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 |
) |
... | ... |
@@ -4,10 +4,10 @@ |
4 | 4 |
\alias{geom_label2} |
5 | 5 |
\title{geom_text2} |
6 | 6 |
\usage{ |
7 |
-geom_label2(mapping = NULL, data = NULL, ..., parse = FALSE, |
|
8 |
- nudge_x = 0, nudge_y = 0, label.padding = unit(0.25, "lines"), |
|
9 |
- label.r = unit(0.15, "lines"), label.size = 0.25, na.rm = TRUE, |
|
10 |
- show.legend = NA, inherit.aes = TRUE) |
|
7 |
+geom_label2(mapping = NULL, data = NULL, ..., family = "sans", |
|
8 |
+ parse = FALSE, nudge_x = 0, nudge_y = 0, label.padding = unit(0.25, |
|
9 |
+ "lines"), label.r = unit(0.15, "lines"), label.size = 0.25, |
|
10 |
+ na.rm = TRUE, show.legend = NA, inherit.aes = TRUE) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
\item{mapping}{the aesthetic mapping} |
... | ... |
@@ -17,6 +17,8 @@ only needed if you want to override he plot defaults.} |
17 | 17 |
|
18 | 18 |
\item{...}{other arguments passed on to 'layer'} |
19 | 19 |
|
20 |
+\item{family}{sans by default, can be any supported font} |
|
21 |
+ |
|
20 | 22 |
\item{parse}{if TRUE, the labels will be passd into expressions} |
21 | 23 |
|
22 | 24 |
\item{nudge_x}{horizontal adjustment} |
... | ... |
@@ -5,8 +5,9 @@ |
5 | 5 |
\title{geom_text2} |
6 | 6 |
\usage{ |
7 | 7 |
geom_text2(mapping = NULL, data = NULL, position = "identity", |
8 |
- parse = FALSE, na.rm = TRUE, show.legend = NA, inherit.aes = TRUE, |
|
9 |
- ..., nudge_x = 0, nudge_y = 0, check_overlap = FALSE) |
|
8 |
+ family = "sans", parse = FALSE, na.rm = TRUE, show.legend = NA, |
|
9 |
+ inherit.aes = TRUE, ..., nudge_x = 0, nudge_y = 0, |
|
10 |
+ check_overlap = FALSE) |
|
10 | 11 |
} |
11 | 12 |
\arguments{ |
12 | 13 |
\item{mapping}{the aesthetic mapping} |
... | ... |
@@ -16,6 +17,8 @@ only needed if you want to override he plot defaults.} |
16 | 17 |
|
17 | 18 |
\item{position}{The position adjustment to use for overlapping points on this layer} |
18 | 19 |
|
20 |
+\item{family}{sans by default, can be any supported font} |
|
21 |
+ |
|
19 | 22 |
\item{parse}{if TRUE, the labels will be passd into expressions} |
20 | 23 |
|
21 | 24 |
\item{na.rm}{logical} |