Skip to content

Commit 9854c58

Browse files
committed
fix test error
1 parent c4882c6 commit 9854c58

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

R/guides-.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ Guides <- ggproto(
509509
) %||% valid.just(calc_element("legend.justification.inside", theme))
510510
inside_positions <- vector("list", length(positions))
511511

512-
# we'll merge inside legends with same coordinate into same guide box
513512
# we grouped the legends by the positions, for inside legends, they'll be
514513
# splitted by the actual inside coordinate
515514
groups <- positions
@@ -556,9 +555,14 @@ Guides <- ggproto(
556555
},
557556

558557
# Render the guides into grobs
559-
draw = function(self, theme, positions, direction = NULL,
558+
draw = function(self, theme, positions = NULL, direction = NULL,
560559
params = self$params,
561560
guides = self$guides) {
561+
positions <- positions %||% vapply(
562+
params,
563+
function(p) p$position[1] %||% "right",
564+
character(1), USE.NAMES = FALSE
565+
)
562566
if (is.null(direction)) {
563567
directions <- ifelse(
564568
positions %in% c("top", "bottom"),

tests/testthat/test-guides.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ test_that("empty guides are dropped", {
156156
expect_equal(nrow(gd), 0)
157157

158158
# Draw guides
159-
guides <- p$plot$guides$draw(theme_gray(), direction = "vertical")
159+
guides <- p$plot$guides$assemble(theme_gray())
160160

161161
# All guide-boxes should be empty
162-
expect_equal(lengths(guides, use.names = FALSE), rep(0, 4))
162+
expect_true(is.zero(guides))
163163
})
164164

165165
test_that("bins can be parsed by guides for all scale types", {

0 commit comments

Comments
 (0)