Skip to content

Commit 3129bf8

Browse files
authored
Make legend.box.background work for theme_void() (tidyverse#2725)
* Provide default option in if--else chain. Closes tidyverse#2723. * add legend.box setting to theme_void() * use `identical` instead of `==`.
1 parent ba2e7ed commit 3129bf8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

R/guides-.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ guides_build <- function(ggrobs, theme) {
248248
yjust <- just[2]
249249

250250
# setting that is different for vertical and horizontal guide-boxes.
251-
if (theme$legend.box == "horizontal") {
251+
if (identical(theme$legend.box, "horizontal")) {
252252
# Set justification for each legend
253253
for (i in seq_along(ggrobs)) {
254254
ggrobs[[i]] <- editGrob(ggrobs[[i]],
@@ -263,7 +263,7 @@ guides_build <- function(ggrobs, theme) {
263263
# add space between the guide-boxes
264264
guides <- gtable_add_col_space(guides, theme$legend.spacing.x)
265265

266-
} else if (theme$legend.box == "vertical") {
266+
} else { # theme$legend.box == "vertical"
267267
# Set justification for each legend
268268
for (i in seq_along(ggrobs)) {
269269
ggrobs[[i]] <- editGrob(ggrobs[[i]],

R/theme-defaults.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ theme_void <- function(base_size = 11, base_family = "",
430430
axis.text = element_blank(),
431431
axis.title = element_blank(),
432432
axis.ticks.length = unit(0, "pt"),
433+
legend.box = NULL,
433434
legend.key.size = unit(1.2, "lines"),
434435
legend.position = "right",
435436
legend.text = element_text(size = rel(0.8)),

0 commit comments

Comments
 (0)