Skip to content

Commit

Permalink
🚑 Fix for revdep problem with adding NULL to theme (#6296)
Browse files Browse the repository at this point in the history
* use `add_theme()` directly

* fallback for invalid `legend.position`
teunbrand authored Jan 28, 2025
1 parent f828794 commit aeaed9a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions R/guides-.R
Original file line number Diff line number Diff line change
@@ -480,7 +480,7 @@ Guides <- ggproto(
if (length(default_position) == 2) {
default_position <- "inside"
}
if (default_position == "none") {
if (!default_position %in% c(.trbl, "inside")) {
return(zeroGrob())
}

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

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

# Determine default direction
direction <- switch(
position,
inside = , left = , right = "vertical",
top = , bottom = "horizontal"
)
direction <- switch(position, top = , bottom = "horizontal", "vertical")

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

0 comments on commit aeaed9a

Please sign in to comment.