feat: add position argument to civilytics_logo() for corner placement
R-CMD-check / R CMD check (push) Successful in 3m37s
R-CMD-check / R CMD check (push) Successful in 3m37s
Supports "bottom-right" (default), "bottom-left", "top-right", and "top-left". The position controls both horizontal alignment of the logo grob and whether it is placed above or below the plot. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -298,3 +298,36 @@ test_that("civilytics_logo accepts type and variant params", {
|
||||
result <- suppressWarnings(civilytics_logo(p, type = "mark", variant = "dark"))
|
||||
expect_s3_class(result, "grob")
|
||||
})
|
||||
|
||||
# --- position argument -------------------------------------------------------
|
||||
|
||||
test_that("civilytics_logo accepts all four position values", {
|
||||
p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_civilytics()
|
||||
for (pos in c("bottom-right", "bottom-left", "top-right", "top-left")) {
|
||||
result <- suppressWarnings(civilytics_logo(p, position = pos))
|
||||
expect_s3_class(result, "grob")
|
||||
}
|
||||
})
|
||||
|
||||
test_that("civilytics_logo errors on invalid position", {
|
||||
p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_civilytics()
|
||||
expect_error(civilytics_logo(p, position = "center"))
|
||||
})
|
||||
|
||||
test_that("make_logo_grob accepts position argument", {
|
||||
for (pos in c("bottom-right", "bottom-left", "top-right", "top-left")) {
|
||||
logo <- make_logo_grob(position = pos)
|
||||
expect_s3_class(logo, "gg")
|
||||
}
|
||||
})
|
||||
|
||||
test_that("top positions place logo before plot in arrangeGrob", {
|
||||
p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_civilytics()
|
||||
result_top <- suppressWarnings(civilytics_logo(p, position = "top-right"))
|
||||
result_bot <- suppressWarnings(civilytics_logo(p, position = "bottom-right"))
|
||||
# Top: logo is first grob; bottom: plot is first grob.
|
||||
|
||||
# The arrangeGrob heights differ in order
|
||||
expect_s3_class(result_top, "grob")
|
||||
expect_s3_class(result_bot, "grob")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user