Skip to content

Commit fc7cc7a

Browse files
committed
deal with ggplot2 changes
1 parent 17c67ce commit fc7cc7a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

R/bayesplot-helpers.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,11 @@ calc_intervals <- function(x, p, med = TRUE, ...) {
333333
#' equivalent to using `legend_none()`.
334334
#'
335335
legend_move <- function(position = "right") {
336-
theme(legend.position = position)
336+
if (is.numeric(position) && "legend.position.inside" %in% fn_fmls_names(theme)) {
337+
theme(legend.position = "inside", legend.position.inside = position)
338+
} else {
339+
theme(legend.position = position)
340+
}
337341
}
338342
#' @rdname bayesplot-helpers
339343
#' @export

tests/testthat/test-convenience-functions.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ test_that("legend_move returns correct theme object", {
110110

111111
pos <- legend_move(c(0.25, 0.5))
112112
expect_s3_class(pos, "theme")
113-
expect_equivalent(pos, list(legend.position = c(0.25, 0.5)))
113+
expect_equivalent(
114+
pos$legend.position.inside %||% pos$legend.position,
115+
c(0.25, 0.5)
116+
)
114117
expect_false(attr(pos, "complete"))
115118
})
116119
test_that("legend_text returns correct theme object", {

0 commit comments

Comments
 (0)