... | ... |
@@ -44,7 +44,7 @@ theme_tree <- function(bgcolor="white", ...) { |
44 | 44 |
##' @importFrom ggplot2 element_text |
45 | 45 |
##' @author Guangchuang Yu |
46 | 46 |
theme_dendrogram <- function(bgcolor = "white", fgcolor = "black", ...) { |
47 |
- list(theme_tree2(bgcolor = bgcolor) |
|
47 |
+ list(theme_tree2(bgcolor = bgcolor), |
|
48 | 48 |
ggfun::theme_noxaxis(color=bgcolor, ...) |
49 | 49 |
) |
50 | 50 |
} |
... | ... |
@@ -44,14 +44,9 @@ theme_tree <- function(bgcolor="white", ...) { |
44 | 44 |
##' @importFrom ggplot2 element_text |
45 | 45 |
##' @author Guangchuang Yu |
46 | 46 |
theme_dendrogram <- function(bgcolor = "white", fgcolor = "black", ...) { |
47 |
- theme_tree2(bgcolor = bgcolor, |
|
48 |
- axis.line.x = element_blank(), |
|
49 |
- axis.text.x = element_blank(), |
|
50 |
- axis.ticks.x = element_blank(), |
|
51 |
- axis.line.y = element_line(color=fgcolor), |
|
52 |
- axis.text.y = element_text(color=fgcolor), |
|
53 |
- axis.ticks.y = element_line(color=fgcolor), |
|
54 |
- ...) |
|
47 |
+ list(theme_tree2(bgcolor = bgcolor) |
|
48 |
+ ggfun::theme_noxaxis(color=bgcolor, ...) |
|
49 |
+ ) |
|
55 | 50 |
} |
56 | 51 |
|
57 | 52 |
|
... | ... |
@@ -121,7 +121,7 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
121 | 121 |
theme_inset <- function(legend.position = "none", ...) { |
122 | 122 |
list(xlab(NULL), |
123 | 123 |
ylab(NULL), |
124 |
- theme_tree(legend.position = legend.position, ...), |
|
124 |
+ theme_tree(legend.position = legend.position, plot.margin = unit(c(0, 0, 0, 0), "lines"), ...), |
|
125 | 125 |
ggfun::theme_transparent() |
126 | 126 |
) |
127 | 127 |
} |
... | ... |
@@ -1,8 +1,9 @@ |
1 | 1 |
##' tree theme |
2 | 2 |
##' |
3 |
+##' 'theme_tree' defines a blank background to display tree |
|
3 | 4 |
##' |
4 | 5 |
##' @title theme_tree |
5 |
-##' @param bgcolor background color |
|
6 |
+##' @param bgcolor set background color, defaults to "white" |
|
6 | 7 |
##' @param ... additional parameter |
7 | 8 |
##' @importFrom ggplot2 theme_void |
8 | 9 |
##' @importFrom ggplot2 theme |
... | ... |
@@ -38,7 +39,7 @@ theme_tree <- function(bgcolor="white", ...) { |
38 | 39 |
##' |
39 | 40 |
##' @title theme_dendrogram |
40 | 41 |
##' @inheritParams theme_tree |
41 |
-##' @param fgcolor color for axis |
|
42 |
+##' @param fgcolor set color of axis |
|
42 | 43 |
##' @export |
43 | 44 |
##' @importFrom ggplot2 element_text |
44 | 45 |
##' @author Guangchuang Yu |
... | ... |
@@ -56,10 +57,11 @@ theme_dendrogram <- function(bgcolor = "white", fgcolor = "black", ...) { |
56 | 57 |
|
57 | 58 |
##' tree2 theme |
58 | 59 |
##' |
60 |
+##' 'theme_tree2' supports displaying phylogenetic distance by setting x-axis |
|
59 | 61 |
##' |
60 | 62 |
##' @title theme_tree2 |
61 |
-##' @param bgcolor background color |
|
62 |
-##' @param fgcolor foreground color |
|
63 |
+##' @param bgcolor set background color, defaults to "white" |
|
64 |
+##' @param fgcolor set foreground color, defaults to "black" |
|
63 | 65 |
##' @param ... additional parameter |
64 | 66 |
##' @importFrom ggplot2 theme_bw |
65 | 67 |
##' @importFrom ggplot2 theme |
... | ... |
@@ -111,7 +113,7 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
111 | 113 |
##' |
112 | 114 |
##' theme for inset function |
113 | 115 |
##' @title theme_inset |
114 |
-##' @param legend.position position of legend |
|
116 |
+##' @param legend.position set the position of legend |
|
115 | 117 |
##' @param ... additional parameter |
116 | 118 |
##' @return ggplot object |
117 | 119 |
##' @export |
... | ... |
@@ -119,12 +119,7 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
119 | 119 |
theme_inset <- function(legend.position = "none", ...) { |
120 | 120 |
list(xlab(NULL), |
121 | 121 |
ylab(NULL), |
122 |
- theme_tree(legend.position = legend.position, |
|
123 |
- function() theme(panel.background = element_rect(fill = "transparent", colour = NA), |
|
124 |
- plot.background = element_rect(fill = "transparent", colour = NA), |
|
125 |
- legend.key = element_rect(fill = "transparent", colour = NA), |
|
126 |
- legend.background = element_rect(fill = "transparent",colour = NA), |
|
127 |
- ...) |
|
128 |
- ) |
|
122 |
+ theme_tree(legend.position = legend.position, ...), |
|
123 |
+ ggfun::theme_transparent() |
|
129 | 124 |
) |
130 | 125 |
} |
... | ... |
@@ -119,7 +119,12 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
119 | 119 |
theme_inset <- function(legend.position = "none", ...) { |
120 | 120 |
list(xlab(NULL), |
121 | 121 |
ylab(NULL), |
122 |
- theme_tree(legend.position = legend.position, ...), |
|
123 |
- ggimage::theme_transparent() |
|
122 |
+ theme_tree(legend.position = legend.position, |
|
123 |
+ function() theme(panel.background = element_rect(fill = "transparent", colour = NA), |
|
124 |
+ plot.background = element_rect(fill = "transparent", colour = NA), |
|
125 |
+ legend.key = element_rect(fill = "transparent", colour = NA), |
|
126 |
+ legend.background = element_rect(fill = "transparent",colour = NA), |
|
127 |
+ ...) |
|
128 |
+ ) |
|
124 | 129 |
) |
125 | 130 |
} |
... | ... |
@@ -111,14 +111,15 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
111 | 111 |
##' |
112 | 112 |
##' theme for inset function |
113 | 113 |
##' @title theme_inset |
114 |
+##' @param legend.position position of legend |
|
114 | 115 |
##' @param ... additional parameter |
115 | 116 |
##' @return ggplot object |
116 | 117 |
##' @export |
117 | 118 |
##' @author Guangchuang Yu |
118 |
-theme_inset <- function(...) { |
|
119 |
+theme_inset <- function(legend.position = "none", ...) { |
|
119 | 120 |
list(xlab(NULL), |
120 | 121 |
ylab(NULL), |
121 |
- theme_tree(...), |
|
122 |
+ theme_tree(legend.position = legend.position, ...), |
|
122 | 123 |
ggimage::theme_transparent() |
123 | 124 |
) |
124 | 125 |
} |
... | ... |
@@ -18,19 +18,19 @@ |
18 | 18 |
##' ggtree(tr) + theme_tree() |
19 | 19 |
theme_tree <- function(bgcolor="white", ...) { |
20 | 20 |
|
21 |
- ## list(xlab(NULL), |
|
22 |
- ## ylab(NULL), |
|
23 |
- ## theme_tree2_internal() + |
|
24 |
- ## theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
25 |
- ## axis.line.x = element_blank(), |
|
26 |
- ## axis.text.x = element_blank(), |
|
27 |
- ## axis.ticks.x = element_blank(), |
|
28 |
- ## ...) |
|
29 |
- ## ) |
|
30 |
- |
|
31 |
- theme_void() + |
|
32 |
- theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
33 |
- ...) |
|
21 |
+ list(xlab(NULL), |
|
22 |
+ ylab(NULL), |
|
23 |
+ theme_tree2_internal() + |
|
24 |
+ theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
25 |
+ axis.line.x = element_blank(), |
|
26 |
+ axis.text.x = element_blank(), |
|
27 |
+ axis.ticks.x = element_blank(), |
|
28 |
+ ...) |
|
29 |
+ ) |
|
30 |
+ |
|
31 |
+ ## theme_void() + |
|
32 |
+ ## theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
33 |
+ ## ...) |
|
34 | 34 |
} |
35 | 35 |
|
36 | 36 |
##' dendrogram theme |
... | ... |
@@ -74,10 +74,10 @@ theme_dendrogram <- function(bgcolor = "white", fgcolor = "black", ...) { |
74 | 74 |
##' tr <- rtree(10) |
75 | 75 |
##' ggtree(tr) + theme_tree2() |
76 | 76 |
theme_tree2 <- function(bgcolor="white", fgcolor="black", ...) { |
77 |
- list(xlab(NULL), |
|
78 |
- ylab(NULL), |
|
79 |
- theme_tree2_internal(bgcolor, fgcolor, ...) |
|
80 |
- ) |
|
77 |
+ list(xlab(NULL), |
|
78 |
+ ylab(NULL), |
|
79 |
+ theme_tree2_internal(bgcolor, fgcolor, ...) |
|
80 |
+ ) |
|
81 | 81 |
} |
82 | 82 |
|
83 | 83 |
##' @importFrom ggplot2 theme_bw |
... | ... |
@@ -3,9 +3,8 @@ |
3 | 3 |
##' |
4 | 4 |
##' @title theme_tree |
5 | 5 |
##' @param bgcolor background color |
6 |
-##' @param fgcolor foreground color |
|
7 | 6 |
##' @param ... additional parameter |
8 |
-##' @importFrom ggplot2 theme_bw |
|
7 |
+##' @importFrom ggplot2 theme_void |
|
9 | 8 |
##' @importFrom ggplot2 theme |
10 | 9 |
##' @importFrom ggplot2 element_blank |
11 | 10 |
##' @importFrom ggplot2 xlab |
... | ... |
@@ -17,16 +16,21 @@ |
17 | 16 |
##' require(ape) |
18 | 17 |
##' tr <- rtree(10) |
19 | 18 |
##' ggtree(tr) + theme_tree() |
20 |
-theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
|
21 |
- list(xlab(NULL), |
|
22 |
- ylab(NULL), |
|
23 |
- theme_tree2_internal() + |
|
24 |
- theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
25 |
- axis.line.x = element_blank(), |
|
26 |
- axis.text.x = element_blank(), |
|
27 |
- axis.ticks.x = element_blank(), |
|
28 |
- ...) |
|
29 |
- ) |
|
19 |
+theme_tree <- function(bgcolor="white", ...) { |
|
20 |
+ |
|
21 |
+ ## list(xlab(NULL), |
|
22 |
+ ## ylab(NULL), |
|
23 |
+ ## theme_tree2_internal() + |
|
24 |
+ ## theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
25 |
+ ## axis.line.x = element_blank(), |
|
26 |
+ ## axis.text.x = element_blank(), |
|
27 |
+ ## axis.ticks.x = element_blank(), |
|
28 |
+ ## ...) |
|
29 |
+ ## ) |
|
30 |
+ |
|
31 |
+ theme_void() + |
|
32 |
+ theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
33 |
+ ...) |
|
30 | 34 |
} |
31 | 35 |
|
32 | 36 |
##' dendrogram theme |
... | ... |
@@ -34,15 +38,19 @@ theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
34 | 38 |
##' |
35 | 39 |
##' @title theme_dendrogram |
36 | 40 |
##' @inheritParams theme_tree |
41 |
+##' @param fgcolor color for axis |
|
37 | 42 |
##' @export |
38 | 43 |
##' @importFrom ggplot2 element_text |
39 | 44 |
##' @author Guangchuang Yu |
40 |
-theme_dendrogram <- function(bgcolor="white", fgcolor="black", ...) { |
|
41 |
- theme_tree(bgcolor = bgcolor, fgcolor = fgcolor, |
|
42 |
- axis.line.y = element_line(color=fgcolor), |
|
43 |
- axis.text.y = element_text(color=fgcolor), |
|
44 |
- axis.ticks.y = element_line(color=fgcolor), |
|
45 |
- ...) |
|
45 |
+theme_dendrogram <- function(bgcolor = "white", fgcolor = "black", ...) { |
|
46 |
+ theme_tree2(bgcolor = bgcolor, |
|
47 |
+ axis.line.x = element_blank(), |
|
48 |
+ axis.text.x = element_blank(), |
|
49 |
+ axis.ticks.x = element_blank(), |
|
50 |
+ axis.line.y = element_line(color=fgcolor), |
|
51 |
+ axis.text.y = element_text(color=fgcolor), |
|
52 |
+ axis.ticks.y = element_line(color=fgcolor), |
|
53 |
+ ...) |
|
46 | 54 |
} |
47 | 55 |
|
48 | 56 |
|
... | ... |
@@ -72,7 +80,7 @@ theme_tree2 <- function(bgcolor="white", fgcolor="black", ...) { |
72 | 80 |
) |
73 | 81 |
} |
74 | 82 |
|
75 |
-##' @importFrom ggplot2 theme_void |
|
83 |
+##' @importFrom ggplot2 theme_bw |
|
76 | 84 |
theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
77 | 85 |
legend.position="right", |
78 | 86 |
panel.grid.minor=element_blank(), |
... | ... |
@@ -83,7 +91,8 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
83 | 91 |
axis.text.y=element_blank(),...) { |
84 | 92 |
## need to set axis.line otherwise the setting cannot be inherited. |
85 | 93 |
## https://github.com/GuangchuangYu/ggtree/issues/218 |
86 |
- theme_void() + |
|
94 |
+ |
|
95 |
+ theme_bw() + |
|
87 | 96 |
theme(legend.position=legend.position, |
88 | 97 |
panel.grid.minor=panel.grid.minor, |
89 | 98 |
panel.grid.major=panel.grid.major, |
... | ... |
@@ -72,8 +72,9 @@ theme_tree2 <- function(bgcolor="white", fgcolor="black", ...) { |
72 | 72 |
) |
73 | 73 |
} |
74 | 74 |
|
75 |
+##' @importFrom ggplot2 theme_void |
|
75 | 76 |
theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
76 |
- legend.position="none", |
|
77 |
+ legend.position="right", |
|
77 | 78 |
panel.grid.minor=element_blank(), |
78 | 79 |
panel.grid.major=element_blank(), |
79 | 80 |
panel.border=element_blank(), |
... | ... |
@@ -82,7 +83,7 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
82 | 83 |
axis.text.y=element_blank(),...) { |
83 | 84 |
## need to set axis.line otherwise the setting cannot be inherited. |
84 | 85 |
## https://github.com/GuangchuangYu/ggtree/issues/218 |
85 |
- theme_bw() + |
|
86 |
+ theme_void() + |
|
86 | 87 |
theme(legend.position=legend.position, |
87 | 88 |
panel.grid.minor=panel.grid.minor, |
88 | 89 |
panel.grid.major=panel.grid.major, |
... | ... |
@@ -12,7 +12,7 @@ |
12 | 12 |
##' @importFrom ggplot2 ylab |
13 | 13 |
##' @export |
14 | 14 |
##' @return updated ggplot object with new theme |
15 |
-##' @author Yu Guangchuang |
|
15 |
+##' @author Guangchuang Yu |
|
16 | 16 |
##' @examples |
17 | 17 |
##' require(ape) |
18 | 18 |
##' tr <- rtree(10) |
... | ... |
@@ -29,6 +29,23 @@ theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
29 | 29 |
) |
30 | 30 |
} |
31 | 31 |
|
32 |
+##' dendrogram theme |
|
33 |
+##' |
|
34 |
+##' |
|
35 |
+##' @title theme_dendrogram |
|
36 |
+##' @inheritParams theme_tree |
|
37 |
+##' @export |
|
38 |
+##' @importFrom ggplot2 element_text |
|
39 |
+##' @author Guangchuang Yu |
|
40 |
+theme_dendrogram <- function(bgcolor="white", fgcolor="black", ...) { |
|
41 |
+ theme_tree(bgcolor = bgcolor, fgcolor = fgcolor, |
|
42 |
+ axis.line.y = element_line(color=fgcolor), |
|
43 |
+ axis.text.y = element_text(color=fgcolor), |
|
44 |
+ axis.ticks.y = element_line(color=fgcolor), |
|
45 |
+ ...) |
|
46 |
+} |
|
47 |
+ |
|
48 |
+ |
|
32 | 49 |
##' tree2 theme |
33 | 50 |
##' |
34 | 51 |
##' |
... | ... |
@@ -43,7 +60,7 @@ theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
43 | 60 |
##' @importFrom ggplot2 element_rect |
44 | 61 |
##' @export |
45 | 62 |
##' @return updated ggplot object with new theme |
46 |
-##' @author Yu Guangchuang |
|
63 |
+##' @author Guangchuang Yu |
|
47 | 64 |
##' @examples |
48 | 65 |
##' require(ape) |
49 | 66 |
##' tr <- rtree(10) |
... | ... |
@@ -63,7 +63,7 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
63 | 63 |
axis.line.y=element_blank(), |
64 | 64 |
axis.ticks.y=element_blank(), |
65 | 65 |
axis.text.y=element_blank(),...) { |
66 |
- ## need to set axis.line otherwise the the settng cannot be inherited. |
|
66 |
+ ## need to set axis.line otherwise the setting cannot be inherited. |
|
67 | 67 |
## https://github.com/GuangchuangYu/ggtree/issues/218 |
68 | 68 |
theme_bw() + |
69 | 69 |
theme(legend.position=legend.position, |
... | ... |
@@ -63,14 +63,16 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
63 | 63 |
axis.line.y=element_blank(), |
64 | 64 |
axis.ticks.y=element_blank(), |
65 | 65 |
axis.text.y=element_blank(),...) { |
66 |
+ ## need to set axis.line otherwise the the settng cannot be inherited. |
|
67 |
+ ## https://github.com/GuangchuangYu/ggtree/issues/218 |
|
66 | 68 |
theme_bw() + |
67 | 69 |
theme(legend.position=legend.position, |
68 | 70 |
panel.grid.minor=panel.grid.minor, |
69 | 71 |
panel.grid.major=panel.grid.major, |
70 | 72 |
panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
71 | 73 |
panel.border=panel.border, |
72 |
- ## axis.line=element_line(color=fgcolor), |
|
73 |
- axis.line.x=element_line(color=fgcolor), |
|
74 |
+ axis.line=element_line(color=fgcolor), |
|
75 |
+ ##axis.line.x=element_line(color=fgcolor), |
|
74 | 76 |
axis.line.y=axis.line.y, |
75 | 77 |
axis.ticks.y=axis.ticks.y, |
76 | 78 |
axis.text.y=axis.text.y, |
... | ... |
@@ -77,32 +77,6 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
77 | 77 |
...) |
78 | 78 |
} |
79 | 79 |
|
80 |
-##' transparent background theme |
|
81 |
-##' |
|
82 |
-##' |
|
83 |
-##' @title theme_transparent |
|
84 |
-##' @param ... additional parameter to tweak the theme |
|
85 |
-##' @return ggplot object |
|
86 |
-##' @importFrom ggplot2 theme |
|
87 |
-##' @importFrom ggplot2 element_rect |
|
88 |
-##' @export |
|
89 |
-##' @author Guangchuang Yu |
|
90 |
-theme_transparent <- function(...) { |
|
91 |
- message("this theme was moved to ggimage::theme_transparent and will be removed in next release") |
|
92 |
- |
|
93 |
- theme(panel.background = element_rect( |
|
94 |
- fill = "transparent", |
|
95 |
- colour = NA), |
|
96 |
- plot.background = element_rect( |
|
97 |
- fill = "transparent", |
|
98 |
- colour = NA), |
|
99 |
- legend.key = element_rect( |
|
100 |
- fill = "transparent", |
|
101 |
- colour = NA), |
|
102 |
- legend.background = element_rect( |
|
103 |
- fill = "transparent", |
|
104 |
- colour = NA), ...) |
|
105 |
-} |
|
106 | 80 |
|
107 | 81 |
##' inset theme |
108 | 82 |
##' |
... | ... |
@@ -113,10 +87,9 @@ theme_transparent <- function(...) { |
113 | 87 |
##' @export |
114 | 88 |
##' @author Guangchuang Yu |
115 | 89 |
theme_inset <- function(...) { |
116 |
- message("this theme will be removed in next release") |
|
117 | 90 |
list(xlab(NULL), |
118 | 91 |
ylab(NULL), |
119 | 92 |
theme_tree(...), |
120 |
- theme_transparent() |
|
93 |
+ ggimage::theme_transparent() |
|
121 | 94 |
) |
122 | 95 |
} |
... | ... |
@@ -20,7 +20,7 @@ |
20 | 20 |
theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
21 | 21 |
list(xlab(NULL), |
22 | 22 |
ylab(NULL), |
23 |
- theme_tree2_internal() + |
|
23 |
+ theme_tree2_internal() + |
|
24 | 24 |
theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
25 | 25 |
axis.line.x = element_blank(), |
26 | 26 |
axis.text.x = element_blank(), |
... | ... |
@@ -63,7 +63,7 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
63 | 63 |
axis.line.y=element_blank(), |
64 | 64 |
axis.ticks.y=element_blank(), |
65 | 65 |
axis.text.y=element_blank(),...) { |
66 |
- theme_bw() + |
|
66 |
+ theme_bw() + |
|
67 | 67 |
theme(legend.position=legend.position, |
68 | 68 |
panel.grid.minor=panel.grid.minor, |
69 | 69 |
panel.grid.major=panel.grid.major, |
... | ... |
@@ -88,6 +88,8 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
88 | 88 |
##' @export |
89 | 89 |
##' @author Guangchuang Yu |
90 | 90 |
theme_transparent <- function(...) { |
91 |
+ message("this theme was moved to ggimage::theme_transparent and will be removed in next release") |
|
92 |
+ |
|
91 | 93 |
theme(panel.background = element_rect( |
92 | 94 |
fill = "transparent", |
93 | 95 |
colour = NA), |
... | ... |
@@ -95,10 +97,10 @@ theme_transparent <- function(...) { |
95 | 97 |
fill = "transparent", |
96 | 98 |
colour = NA), |
97 | 99 |
legend.key = element_rect( |
98 |
- fill = "transparent", |
|
100 |
+ fill = "transparent", |
|
99 | 101 |
colour = NA), |
100 | 102 |
legend.background = element_rect( |
101 |
- fill = "transparent", |
|
103 |
+ fill = "transparent", |
|
102 | 104 |
colour = NA), ...) |
103 | 105 |
} |
104 | 106 |
|
... | ... |
@@ -111,6 +113,7 @@ theme_transparent <- function(...) { |
111 | 113 |
##' @export |
112 | 114 |
##' @author Guangchuang Yu |
113 | 115 |
theme_inset <- function(...) { |
116 |
+ message("this theme will be removed in next release") |
|
114 | 117 |
list(xlab(NULL), |
115 | 118 |
ylab(NULL), |
116 | 119 |
theme_tree(...), |
... | ... |
@@ -93,10 +93,10 @@ theme_transparent <- function(...) { |
93 | 93 |
colour = NA), |
94 | 94 |
plot.background = element_rect( |
95 | 95 |
fill = "transparent", |
96 |
- colour = NA), ...), |
|
96 |
+ colour = NA), |
|
97 | 97 |
legend.key = element_rect( |
98 | 98 |
fill = "transparent", |
99 |
- colour = NA), ...), |
|
99 |
+ colour = NA), |
|
100 | 100 |
legend.background = element_rect( |
101 | 101 |
fill = "transparent", |
102 | 102 |
colour = NA), ...) |
... | ... |
@@ -96,10 +96,10 @@ theme_transparent <- function(...) { |
96 | 96 |
colour = NA), ...), |
97 | 97 |
legend.key = element_rect( |
98 | 98 |
fill = "transparent", |
99 |
- colour = NA, ...), |
|
99 |
+ colour = NA), ...), |
|
100 | 100 |
legend.background = element_rect( |
101 | 101 |
fill = "transparent", |
102 |
- colour = NA, ...) |
|
102 |
+ colour = NA), ...) |
|
103 | 103 |
} |
104 | 104 |
|
105 | 105 |
##' inset theme |
... | ... |
@@ -93,7 +93,13 @@ theme_transparent <- function(...) { |
93 | 93 |
colour = NA), |
94 | 94 |
plot.background = element_rect( |
95 | 95 |
fill = "transparent", |
96 |
- colour = NA), ...) |
|
96 |
+ colour = NA), ...), |
|
97 |
+ legend.key = element_rect( |
|
98 |
+ fill = "transparent", |
|
99 |
+ colour = NA, ...), |
|
100 |
+ legend.background = element_rect( |
|
101 |
+ fill = "transparent", |
|
102 |
+ colour = NA, ...) |
|
97 | 103 |
} |
98 | 104 |
|
99 | 105 |
##' inset theme |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@122021 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -8,7 +8,6 @@ |
8 | 8 |
##' @importFrom ggplot2 theme_bw |
9 | 9 |
##' @importFrom ggplot2 theme |
10 | 10 |
##' @importFrom ggplot2 element_blank |
11 |
-##' @importFrom ggplot2 %+replace% |
|
12 | 11 |
##' @importFrom ggplot2 xlab |
13 | 12 |
##' @importFrom ggplot2 ylab |
14 | 13 |
##' @export |
... | ... |
@@ -21,12 +20,12 @@ |
21 | 20 |
theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
22 | 21 |
list(xlab(NULL), |
23 | 22 |
ylab(NULL), |
24 |
- theme_tree2_internal() %+replace% |
|
25 |
- theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
26 |
- axis.line.x = element_blank(), |
|
27 |
- axis.text.x = element_blank(), |
|
28 |
- axis.ticks.x = element_blank(), |
|
29 |
- ...) |
|
23 |
+ theme_tree2_internal() + |
|
24 |
+ theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
25 |
+ axis.line.x = element_blank(), |
|
26 |
+ axis.text.x = element_blank(), |
|
27 |
+ axis.ticks.x = element_blank(), |
|
28 |
+ ...) |
|
30 | 29 |
) |
31 | 30 |
} |
32 | 31 |
|
... | ... |
@@ -41,7 +40,6 @@ theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
41 | 40 |
##' @importFrom ggplot2 theme |
42 | 41 |
##' @importFrom ggplot2 element_blank |
43 | 42 |
##' @importFrom ggplot2 element_line |
44 |
-##' @importFrom ggplot2 %+replace% |
|
45 | 43 |
##' @importFrom ggplot2 element_rect |
46 | 44 |
##' @export |
47 | 45 |
##' @return updated ggplot object with new theme |
... | ... |
@@ -65,18 +63,18 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
65 | 63 |
axis.line.y=element_blank(), |
66 | 64 |
axis.ticks.y=element_blank(), |
67 | 65 |
axis.text.y=element_blank(),...) { |
68 |
- theme_bw() %+replace% |
|
69 |
- theme(legend.position=legend.position, |
|
70 |
- panel.grid.minor=panel.grid.minor, |
|
71 |
- panel.grid.major=panel.grid.major, |
|
72 |
- panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
73 |
- panel.border=panel.border, |
|
74 |
- ## axis.line=element_line(color=fgcolor), |
|
75 |
- axis.line.x=element_line(color=fgcolor), |
|
76 |
- axis.line.y=axis.line.y, |
|
77 |
- axis.ticks.y=axis.ticks.y, |
|
78 |
- axis.text.y=axis.text.y, |
|
79 |
- ...) |
|
66 |
+ theme_bw() + |
|
67 |
+ theme(legend.position=legend.position, |
|
68 |
+ panel.grid.minor=panel.grid.minor, |
|
69 |
+ panel.grid.major=panel.grid.major, |
|
70 |
+ panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
71 |
+ panel.border=panel.border, |
|
72 |
+ ## axis.line=element_line(color=fgcolor), |
|
73 |
+ axis.line.x=element_line(color=fgcolor), |
|
74 |
+ axis.line.y=axis.line.y, |
|
75 |
+ axis.ticks.y=axis.ticks.y, |
|
76 |
+ axis.text.y=axis.text.y, |
|
77 |
+ ...) |
|
80 | 78 |
} |
81 | 79 |
|
82 | 80 |
##' transparent background theme |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@121780 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
##' tree theme |
2 | 2 |
##' |
3 |
-##' |
|
3 |
+##' |
|
4 | 4 |
##' @title theme_tree |
5 | 5 |
##' @param bgcolor background color |
6 | 6 |
##' @param fgcolor foreground color |
... | ... |
@@ -32,7 +32,7 @@ theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
32 | 32 |
|
33 | 33 |
##' tree2 theme |
34 | 34 |
##' |
35 |
-##' |
|
35 |
+##' |
|
36 | 36 |
##' @title theme_tree2 |
37 | 37 |
##' @param bgcolor background color |
38 | 38 |
##' @param fgcolor foreground color |
... | ... |
@@ -57,24 +57,31 @@ theme_tree2 <- function(bgcolor="white", fgcolor="black", ...) { |
57 | 57 |
) |
58 | 58 |
} |
59 | 59 |
|
60 |
-theme_tree2_internal <- function(bgcolor="white", fgcolor="black", ...) { |
|
60 |
+theme_tree2_internal <- function(bgcolor="white", fgcolor="black", |
|
61 |
+ legend.position="none", |
|
62 |
+ panel.grid.minor=element_blank(), |
|
63 |
+ panel.grid.major=element_blank(), |
|
64 |
+ panel.border=element_blank(), |
|
65 |
+ axis.line.y=element_blank(), |
|
66 |
+ axis.ticks.y=element_blank(), |
|
67 |
+ axis.text.y=element_blank(),...) { |
|
61 | 68 |
theme_bw() %+replace% |
62 |
- theme(legend.position="none", |
|
63 |
- panel.grid.minor=element_blank(), |
|
64 |
- panel.grid.major=element_blank(), |
|
69 |
+ theme(legend.position=legend.position, |
|
70 |
+ panel.grid.minor=panel.grid.minor, |
|
71 |
+ panel.grid.major=panel.grid.major, |
|
65 | 72 |
panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
66 |
- panel.border=element_blank(), |
|
73 |
+ panel.border=panel.border, |
|
67 | 74 |
## axis.line=element_line(color=fgcolor), |
68 | 75 |
axis.line.x=element_line(color=fgcolor), |
69 |
- axis.line.y=element_blank(), |
|
70 |
- axis.ticks.y=element_blank(), |
|
71 |
- axis.text.y=element_blank(), |
|
76 |
+ axis.line.y=axis.line.y, |
|
77 |
+ axis.ticks.y=axis.ticks.y, |
|
78 |
+ axis.text.y=axis.text.y, |
|
72 | 79 |
...) |
73 | 80 |
} |
74 | 81 |
|
75 | 82 |
##' transparent background theme |
76 | 83 |
##' |
77 |
-##' |
|
84 |
+##' |
|
78 | 85 |
##' @title theme_transparent |
79 | 86 |
##' @param ... additional parameter to tweak the theme |
80 | 87 |
##' @return ggplot object |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@114268 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -64,8 +64,8 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", ...) { |
64 | 64 |
panel.grid.major=element_blank(), |
65 | 65 |
panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
66 | 66 |
panel.border=element_blank(), |
67 |
- axis.line=element_line(color=fgcolor), |
|
68 |
- axis.line.x=element_line(), |
|
67 |
+ ## axis.line=element_line(color=fgcolor), |
|
68 |
+ axis.line.x=element_line(color=fgcolor), |
|
69 | 69 |
axis.line.y=element_blank(), |
70 | 70 |
axis.ticks.y=element_blank(), |
71 | 71 |
axis.text.y=element_blank(), |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@114267 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -65,6 +65,7 @@ theme_tree2_internal <- function(bgcolor="white", fgcolor="black", ...) { |
65 | 65 |
panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
66 | 66 |
panel.border=element_blank(), |
67 | 67 |
axis.line=element_line(color=fgcolor), |
68 |
+ axis.line.x=element_line(), |
|
68 | 69 |
axis.line.y=element_blank(), |
69 | 70 |
axis.ticks.y=element_blank(), |
70 | 71 |
axis.text.y=element_blank(), |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@112408 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -9,6 +9,8 @@ |
9 | 9 |
##' @importFrom ggplot2 theme |
10 | 10 |
##' @importFrom ggplot2 element_blank |
11 | 11 |
##' @importFrom ggplot2 %+replace% |
12 |
+##' @importFrom ggplot2 xlab |
|
13 |
+##' @importFrom ggplot2 ylab |
|
12 | 14 |
##' @export |
13 | 15 |
##' @return updated ggplot object with new theme |
14 | 16 |
##' @author Yu Guangchuang |
... | ... |
@@ -17,12 +19,15 @@ |
17 | 19 |
##' tr <- rtree(10) |
18 | 20 |
##' ggtree(tr) + theme_tree() |
19 | 21 |
theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
20 |
- theme_tree2() %+replace% |
|
21 |
- theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
22 |
- axis.line.x = element_blank(), |
|
23 |
- axis.text.x = element_blank(), |
|
24 |
- axis.ticks.x = element_blank(), |
|
25 |
- ...) |
|
22 |
+ list(xlab(NULL), |
|
23 |
+ ylab(NULL), |
|
24 |
+ theme_tree2_internal() %+replace% |
|
25 |
+ theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
26 |
+ axis.line.x = element_blank(), |
|
27 |
+ axis.text.x = element_blank(), |
|
28 |
+ axis.ticks.x = element_blank(), |
|
29 |
+ ...) |
|
30 |
+ ) |
|
26 | 31 |
} |
27 | 32 |
|
28 | 33 |
##' tree2 theme |
... | ... |
@@ -46,6 +51,13 @@ theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
46 | 51 |
##' tr <- rtree(10) |
47 | 52 |
##' ggtree(tr) + theme_tree2() |
48 | 53 |
theme_tree2 <- function(bgcolor="white", fgcolor="black", ...) { |
54 |
+ list(xlab(NULL), |
|
55 |
+ ylab(NULL), |
|
56 |
+ theme_tree2_internal(bgcolor, fgcolor, ...) |
|
57 |
+ ) |
|
58 |
+} |
|
59 |
+ |
|
60 |
+theme_tree2_internal <- function(bgcolor="white", fgcolor="black", ...) { |
|
49 | 61 |
theme_bw() %+replace% |
50 | 62 |
theme(legend.position="none", |
51 | 63 |
panel.grid.minor=element_blank(), |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@112112 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -77,3 +77,19 @@ theme_transparent <- function(...) { |
77 | 77 |
fill = "transparent", |
78 | 78 |
colour = NA), ...) |
79 | 79 |
} |
80 |
+ |
|
81 |
+##' inset theme |
|
82 |
+##' |
|
83 |
+##' theme for inset function |
|
84 |
+##' @title theme_inset |
|
85 |
+##' @param ... additional parameter |
|
86 |
+##' @return ggplot object |
|
87 |
+##' @export |
|
88 |
+##' @author Guangchuang Yu |
|
89 |
+theme_inset <- function(...) { |
|
90 |
+ list(xlab(NULL), |
|
91 |
+ ylab(NULL), |
|
92 |
+ theme_tree(...), |
|
93 |
+ theme_transparent() |
|
94 |
+ ) |
|
95 |
+} |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@111939 bc3139a8-67e5-0310-9ffc-ced21a209358
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,79 @@ |
1 |
+##' tree theme |
|
2 |
+##' |
|
3 |
+##' |
|
4 |
+##' @title theme_tree |
|
5 |
+##' @param bgcolor background color |
|
6 |
+##' @param fgcolor foreground color |
|
7 |
+##' @param ... additional parameter |
|
8 |
+##' @importFrom ggplot2 theme_bw |
|
9 |
+##' @importFrom ggplot2 theme |
|
10 |
+##' @importFrom ggplot2 element_blank |
|
11 |
+##' @importFrom ggplot2 %+replace% |
|
12 |
+##' @export |
|
13 |
+##' @return updated ggplot object with new theme |
|
14 |
+##' @author Yu Guangchuang |
|
15 |
+##' @examples |
|
16 |
+##' require(ape) |
|
17 |
+##' tr <- rtree(10) |
|
18 |
+##' ggtree(tr) + theme_tree() |
|
19 |
+theme_tree <- function(bgcolor="white", fgcolor="black", ...) { |
|
20 |
+ theme_tree2() %+replace% |
|
21 |
+ theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
22 |
+ axis.line.x = element_blank(), |
|
23 |
+ axis.text.x = element_blank(), |
|
24 |
+ axis.ticks.x = element_blank(), |
|
25 |
+ ...) |
|
26 |
+} |
|
27 |
+ |
|
28 |
+##' tree2 theme |
|
29 |
+##' |
|
30 |
+##' |
|
31 |
+##' @title theme_tree2 |
|
32 |
+##' @param bgcolor background color |
|
33 |
+##' @param fgcolor foreground color |
|
34 |
+##' @param ... additional parameter |
|
35 |
+##' @importFrom ggplot2 theme_bw |
|
36 |
+##' @importFrom ggplot2 theme |
|
37 |
+##' @importFrom ggplot2 element_blank |
|
38 |
+##' @importFrom ggplot2 element_line |
|
39 |
+##' @importFrom ggplot2 %+replace% |
|
40 |
+##' @importFrom ggplot2 element_rect |
|
41 |
+##' @export |
|
42 |
+##' @return updated ggplot object with new theme |
|
43 |
+##' @author Yu Guangchuang |
|
44 |
+##' @examples |
|
45 |
+##' require(ape) |
|
46 |
+##' tr <- rtree(10) |
|
47 |
+##' ggtree(tr) + theme_tree2() |
|
48 |
+theme_tree2 <- function(bgcolor="white", fgcolor="black", ...) { |
|
49 |
+ theme_bw() %+replace% |
|
50 |
+ theme(legend.position="none", |
|
51 |
+ panel.grid.minor=element_blank(), |
|
52 |
+ panel.grid.major=element_blank(), |
|
53 |
+ panel.background=element_rect(fill=bgcolor, colour=bgcolor), |
|
54 |
+ panel.border=element_blank(), |
|
55 |
+ axis.line=element_line(color=fgcolor), |
|
56 |
+ axis.line.y=element_blank(), |
|
57 |
+ axis.ticks.y=element_blank(), |
|
58 |
+ axis.text.y=element_blank(), |
|
59 |
+ ...) |
|
60 |
+} |
|
61 |
+ |
|
62 |
+##' transparent background theme |
|
63 |
+##' |
|
64 |
+##' |
|
65 |
+##' @title theme_transparent |
|
66 |
+##' @param ... additional parameter to tweak the theme |
|
67 |
+##' @return ggplot object |
|
68 |
+##' @importFrom ggplot2 theme |
|
69 |
+##' @importFrom ggplot2 element_rect |
|
70 |
+##' @export |
|
71 |
+##' @author Guangchuang Yu |
|
72 |
+theme_transparent <- function(...) { |
|
73 |
+ theme(panel.background = element_rect( |
|
74 |
+ fill = "transparent", |
|
75 |
+ colour = NA), |
|
76 |
+ plot.background = element_rect( |
|
77 |
+ fill = "transparent", |
|
78 |
+ colour = NA), ...) |
|
79 |
+} |