feat: add position argument to civilytics_logo() for corner placement
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:
2026-05-19 15:44:18 -06:00
co-authored by Claude Opus 4.6
parent 95b8ba1da4
commit 328d9d2fd6
5 changed files with 152 additions and 41 deletions
+23 -11
View File
@@ -8,6 +8,7 @@ civilytics_logo(
plot,
type = c("wordmark", "mark"),
variant = c("light", "dark"),
position = c("bottom-right", "bottom-left", "top-right", "top-left"),
margin_param = NULL,
font_scale = 1.1
)
@@ -21,6 +22,9 @@ civilytics_logo(
\item{variant}{Character. `"light"` (default) or `"dark"`. Passed to
[make_logo_grob()].}
\item{position}{Character. Corner placement for the logo: `"bottom-right"`
(default), `"bottom-left"`, `"top-right"`, or `"top-left"`.}
\item{margin_param}{Numeric or `NULL`. Manual margin adjustment passed to
[add_logo()].}
@@ -33,8 +37,8 @@ A grob (from [gridExtra::arrangeGrob()]) ready to draw with
[grid::grid.draw()].
}
\description{
A convenience wrapper that creates the logo grob and attaches it below the
plot in one call. Designed for use with the base pipe `|>`.
A convenience wrapper that creates the logo grob and attaches it to a
corner of the plot in one call. Designed for use with the base pipe `|>`.
}
\details{
**Important:** R's `|>` has *higher* precedence than `+`, so you must
@@ -58,18 +62,26 @@ library(ggplot2); library(grid)
civilytics_logo() |>
grid.draw()
# Dark theme with mark
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics_dark()) |>
civilytics_logo(variant = "dark", type = "mark") |>
grid.draw()
# Disable font inflation
# Top-right placement
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics()) |>
civilytics_logo(font_scale = 1) |>
civilytics_logo(position = "top-right") |>
grid.draw()
# Bottom-left with mark
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics()) |>
civilytics_logo(type = "mark", position = "bottom-left") |>
grid.draw()
# Dark theme with mark in top-left
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics_dark()) |>
civilytics_logo(variant = "dark", type = "mark",
position = "top-left") |>
grid.draw()
}
}