Skip to content

Commit aeaed9a

Browse files
authored
🚑 Fix for revdep problem with adding NULL to theme (#6296)
* use `add_theme()` directly * fallback for invalid `legend.position`
1 parent f828794 commit aeaed9a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

‎R/guides-.R

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ Guides <- ggproto(
480480
if (length(default_position) == 2) {
481481
default_position <- "inside"
482482
}
483-
if (default_position == "none") {
483+
if (!default_position %in% c(.trbl, "inside")) {
484484
return(zeroGrob())
485485
}
486486

@@ -547,7 +547,8 @@ Guides <- ggproto(
547547
legend.justification.inside = groups$key$justs[[i]]
548548
)
549549
}
550-
grobs[[i]] <- self$package_box(grobs[[i]], position, theme + adjust)
550+
adjust <- add_theme(theme, adjust, "internal theme settings")
551+
grobs[[i]] <- self$package_box(grobs[[i]], position, adjust)
551552
}
552553

553554
# merge inside grobs into single gtable
@@ -598,11 +599,7 @@ Guides <- ggproto(
598599
}
599600

600601
# Determine default direction
601-
direction <- switch(
602-
position,
603-
inside = , left = , right = "vertical",
604-
top = , bottom = "horizontal"
605-
)
602+
direction <- switch(position, top = , bottom = "horizontal", "vertical")
606603

607604
# Populate missing theme arguments
608605
theme$legend.box <- theme$legend.box %||% direction

0 commit comments

Comments
 (0)