Browse code

add family parameter in geom_cladelabel

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

g.yu authored on 11/03/2016 04:31:20
Showing 2 changed files

... ...
@@ -13,13 +13,14 @@
13 13
 ##' @param geom one of 'text' or 'label'
14 14
 ##' @param hjust hjust
15 15
 ##' @param fill fill label background, only work with geom='label'
16
+##' @param family sans by default, can be any supported font
16 17
 ##' @param ... additional parameter
17 18
 ##' @return ggplot layers
18 19
 ##' @export
19 20
 ##' @author Guangchuang Yu
20 21
 geom_cladelabel <- function(node, label, offset=0, offset.text=0,
21 22
                             align=FALSE, barsize=0.5, fontsize=3.88,
22
-                            angle=0, geom="text", hjust = 0, fill=NA, ...) {
23
+                            angle=0, geom="text", hjust = 0, fill=NA, family="sans", ...) {
23 24
     mapping <- NULL
24 25
     data <- NULL
25 26
     position <- "identity"
... ...
@@ -30,14 +31,14 @@ geom_cladelabel <- function(node, label, offset=0, offset.text=0,
30 31
     if (geom == "text") {
31 32
         ## no fill parameter
32 33
         layer_text = stat_cladeText(node=node, label=label, offset=offset+offset.text,
33
-                                    align=align, size=fontsize, angle=angle,
34
+                                    align=align, size=fontsize, angle=angle, family=family,
34 35
                                     mapping=mapping, data=data, geom=geom, hjust=hjust,
35 36
                                     position=position, show.legend = show.legend,
36 37
                                     inherit.aes = inherit.aes, na.rm=na.rm, ...)
37 38
         
38 39
     } else {
39 40
         layer_text = stat_cladeText(node=node, label=label, offset=offset+offset.text,
40
-                                    align=align, size=fontsize, angle=angle, fill=fill,
41
+                                    align=align, size=fontsize, angle=angle, fill=fill,family=family,
41 42
                                     mapping=mapping, data=data, geom=geom, hjust=hjust,
42 43
                                     position=position, show.legend = show.legend,
43 44
                                     inherit.aes = inherit.aes, na.rm=na.rm, ...)
... ...
@@ -6,7 +6,7 @@
6 6
 \usage{
7 7
 geom_cladelabel(node, label, offset = 0, offset.text = 0, align = FALSE,
8 8
   barsize = 0.5, fontsize = 3.88, angle = 0, geom = "text", hjust = 0,
9
-  fill = NA, ...)
9
+  fill = NA, family = "sans", ...)
10 10
 }
11 11
 \arguments{
12 12
 \item{node}{selected node}
... ...
@@ -31,6 +31,8 @@ geom_cladelabel(node, label, offset = 0, offset.text = 0, align = FALSE,
31 31
 
32 32
 \item{fill}{fill label background, only work with geom='label'}
33 33
 
34
+\item{family}{sans by default, can be any supported font}
35
+
34 36
 \item{...}{additional parameter}
35 37
 }
36 38
 \value{