Skip to content

Commit 92f57f8

Browse files
committed
fix R CMD check error
1 parent 04827f5 commit 92f57f8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

R/guides-.R

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,20 +518,26 @@ Guides <- ggproto(
518518
for (i in seq_along(positions)) {
519519
if (identical(positions[i], "inside")) {
520520
# the actual inside position and justification can be set in each guide
521-
# by `theme` argument
522-
inside_justs[[i]] <- valid.just(calc_element(
523-
"legend.justification.inside", params[[i]]$theme
524-
)) %||% default_inside_just
525-
inside_positions[[i]] <- calc_element(
526-
"legend.position.inside", params[[i]]$theme
527-
) %||% default_inside_position %||% inside_justs[[i]]
521+
# by `theme` argument, here, we won't use `calc_element()` which will
522+
# use inherits from `legend.justification` or `legend.position`, we only
523+
# follow the inside elements from the guide theme
524+
inside_just <- params[[i]]$theme[["legend.justification.inside"]]
525+
if (is.null(inside_just)) {
526+
inside_justs[[i]] <- default_inside_just
527+
} else {
528+
inside_justs[[i]] <- valid.just(inside_just)
529+
}
530+
inside_positions[[i]] <- params[[i]]$theme[[
531+
"legend.position.inside"
532+
]] %||% default_inside_position %||% inside_justs[[i]]
528533
groups[i] <- paste("inside",
529534
paste(inside_positions[[i]], collapse = "_"),
530535
paste(inside_justs[[i]], collapse = "_"),
531536
sep = "_"
532537
)
533538
}
534539
}
540+
535541
positions <- positions[keep]
536542
inside_positions <- inside_positions[keep]
537543
inside_justs <- inside_justs[keep]
@@ -595,7 +601,7 @@ Guides <- ggproto(
595601

596602
# here, we put `inside_position` in the last, so that it won't break current
597603
# implement of patchwork
598-
package_box = function(grobs, position, theme,
604+
package_box = function(grobs, position, theme,
599605
inside_position = NULL, inside_just = NULL) {
600606
if (is.zero(grobs) || length(grobs) == 0) {
601607
return(zeroGrob())

0 commit comments

Comments
 (0)