1
- # ' @importFrom ggplot2 theme_classic
2
- default_theme <- function () theme_classic()
1
+ # ' @importFrom ggplot2 theme_bw element_blank
2
+ default_theme <- function () {
3
+ if (is_theme_unset()) {
4
+ theme_bw() + theme(
5
+ panel.border = element_blank(),
6
+ panel.grid = element_blank()
7
+ )
8
+ } else {
9
+ theme_get()
10
+ }
11
+ }
3
12
4
- # ' @importFrom ggplot2 rel element_line element_rect element_text
5
- theme_add_panel <- function (base_size = 11 ) {
6
- half_line <- base_size / 2
7
- theme(
8
- panel.border = element_rect(fill = NA , colour = " grey20" ),
9
- panel.grid = element_line(colour = " grey92" ),
10
- panel.grid.minor = element_line(linewidth = rel(0.5 )),
11
- panel.background = element_rect(fill = " white" , colour = NA ),
12
- strip.background = element_rect(
13
- fill = " white" , colour = " black" , linewidth = rel(2 )
14
- ),
15
- strip.clip = " inherit" ,
16
- strip.text = element_text(
17
- colour = " grey10" , size = rel(0.8 ),
18
- margin = margin(
19
- 0.8 * half_line , 0.8 * half_line ,
20
- 0.8 * half_line , 0.8 * half_line
21
- )
22
- ),
23
- strip.text.x = NULL ,
24
- strip.text.y = element_text(angle = - 90 ),
25
- strip.text.y.left = element_text(angle = 90 )
26
- )
13
+ # Check if user has set the theme
14
+ is_theme_unset <- function () {
15
+ isTRUE(all.equal(
16
+ .subset2(ggfun(" ggplot_global" ), " theme_default" ),
17
+ complete_theme(theme_get())
18
+ ))
27
19
}
28
20
29
- # ' @importFrom ggplot2 element_blank
30
- theme_no_panel <- function (... ) {
21
+ is_theme_complete <- function (x ) isTRUE(attr(x , " complete" , exact = TRUE ))
22
+
23
+ # ' @importFrom ggplot2 rel element_blank
24
+ theme_no_strip <- function () {
31
25
theme(
32
- panel.border = element_blank(),
33
- panel.grid.major = element_blank(),
34
- panel.grid.minor = element_blank(),
35
- axis.line = element_blank(),
36
26
strip.text = element_blank(),
37
- strip.background = element_blank(),
38
- plot.background = element_blank()
27
+ strip.background = element_blank()
39
28
)
40
29
}
41
30
@@ -47,8 +36,6 @@ complete_theme <- function(theme) {
47
36
)
48
37
}
49
38
50
- is_theme_complete <- function (x ) isTRUE(attr(x , " complete" , exact = TRUE ))
51
-
52
39
# ' @importFrom ggplot2 register_theme_elements el_def element_line
53
40
theme_elements <- function () {
54
41
register_theme_elements(
0 commit comments