Skip to content

Commit bc5d632

Browse files
committed
set paper backgrounds
1 parent 1bfb3c9 commit bc5d632

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

R/theme-defaults.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ theme_minimal <- function(base_size = 11, base_family = "",
472472
panel.background = element_blank(),
473473
panel.border = element_blank(),
474474
strip.background = element_blank(),
475-
plot.background = element_blank(),
475+
plot.background = element_rect(fill = paper, colour = NA),
476476

477477
complete = TRUE
478478
)
@@ -553,7 +553,7 @@ theme_void <- function(base_size = 11, base_family = "",
553553
header_family = NULL,
554554
base_line_size = base_size / 22,
555555
base_rect_size = base_size / 22,
556-
ink = "black", paper = "white") {
556+
ink = "black", paper = alpha(ink, 0)) {
557557
half_line <- base_size / 2
558558

559559
# Only keep indispensable text: legend and plot titles
@@ -621,6 +621,13 @@ theme_void <- function(base_size = 11, base_family = "",
621621
plot.tag.position = 'topleft',
622622

623623
complete = TRUE
624+
) + theme(
625+
# Contrary to default behaviour, we do not want to inherit the plot
626+
# background from a blank root element
627+
plot.background = element_rect(
628+
fill = paper, colour = NA, linewidth = 0, linetype = 1,
629+
inherit.blank = FALSE
630+
)
624631
)
625632

626633
# make sure all elements are set to NULL if not explicitly defined

0 commit comments

Comments
 (0)