Browse code

facet_labeller

Guangchuang Yu authored on 10/09/2018 10:16:41
Showing 5 changed files

... ...
@@ -2,7 +2,7 @@ Package: ggtree
2 2
 Type: Package
3 3
 Title: an R package for visualization and annotation of phylogenetic trees with
4 4
     their covariates and other associated data
5
-Version: 1.13.3
5
+Version: 1.13.4
6 6
 Authors@R: c(
7 7
 	   person("Guangchuang", "Yu",     email = "guangchuangyu@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0002-6485-8781")),
8 8
 	   person("Tommy Tsan-Yuk", "Lam", email = "tylam.tommy@gmail.com",   role = c("aut", "ths")),
... ...
@@ -28,6 +28,7 @@ export(as.polytomy)
28 28
 export(collapse)
29 29
 export(decimal2Date)
30 30
 export(expand)
31
+export(facet_labeller)
31 32
 export(facet_plot)
32 33
 export(flip)
33 34
 export(fortify)
... ...
@@ -173,6 +174,7 @@ importFrom(ggplot2,ggproto)
173 174
 importFrom(ggplot2,ggsave)
174 175
 importFrom(ggplot2,guide_legend)
175 176
 importFrom(ggplot2,guides)
177
+importFrom(ggplot2,labeller)
176 178
 importFrom(ggplot2,last_plot)
177 179
 importFrom(ggplot2,layer)
178 180
 importFrom(ggplot2,position_nudge)
... ...
@@ -1,3 +1,8 @@
1
+# ggtree 1.13.4
2
+
3
++ `facet_labeller` to label panels of `facet_plot` output (2018-09-10, Mon)
4
+  - <https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/bioc-ggtree/nAl3bNswxQM/crBwKtS3BAAJ>
5
+  
1 6
 # ggtree 1.13.3
2 7
 
3 8
 + update `viewClade` according to the change of `ggplot2` (2018-08-07, Tue)
... ...
@@ -25,6 +25,21 @@ facet_plot <- function(p, panel, data, geom, mapping=NULL, ...) {
25 25
     p + geom(data=df, mapping=mapping, ...)
26 26
 }
27 27
 
28
+##' label facet_plot output
29
+##'
30
+##' 
31
+##' @title facet_labeller
32
+##' @param p facet_plot output
33
+##' @param label labels of facet panels
34
+##' @return ggplot object
35
+##' @importFrom ggplot2 labeller
36
+##' @export
37
+##' @author Guangchuang Yu
38
+facet_labeller <- function(p, label) {
39
+    p+ facet_grid( . ~ .panel, scales="free_x",
40
+               labeller = labeller(.panel = label))
41
+}
42
+
28 43
 ##' @importFrom ggplot2 facet_grid
29 44
 add_panel <- function(p, panel) {
30 45
     df <- p$data
31 46
new file mode 100644
... ...
@@ -0,0 +1,22 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/facet_plot.R
3
+\name{facet_labeller}
4
+\alias{facet_labeller}
5
+\title{facet_labeller}
6
+\usage{
7
+facet_labeller(p, label)
8
+}
9
+\arguments{
10
+\item{p}{facet_plot output}
11
+
12
+\item{label}{labels of facet panels}
13
+}
14
+\value{
15
+ggplot object
16
+}
17
+\description{
18
+label facet_plot output
19
+}
20
+\author{
21
+Guangchuang Yu
22
+}