Files
civilyticsR/man/civilytics_logo.Rd
jaredandClaude Opus 4.6 328d9d2fd6
R-CMD-check / R CMD check (push) Successful in 3m37s
feat: add position argument to civilytics_logo() for corner placement
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>
2026-05-19 15:44:18 -06:00

88 lines
2.3 KiB
R

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/logo.R
\name{civilytics_logo}
\alias{civilytics_logo}
\title{Add a Civilytics logo to a ggplot (pipe-friendly)}
\usage{
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
)
}
\arguments{
\item{plot}{A ggplot object.}
\item{type}{Character. `"wordmark"` (default) or `"mark"`. Passed to
[make_logo_grob()].}
\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()].}
\item{font_scale}{Numeric. Inflate text sizes by this factor to compensate
for viewport shrinkage when composing with [gridExtra::arrangeGrob()].
Default `1.1` (~10 \% inflation). Set to `1` to disable.}
}
\value{
A grob (from [gridExtra::arrangeGrob()]) ready to draw with
[grid::grid.draw()].
}
\description{
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
wrap the ggplot chain in parentheses before piping:
```
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics()) |>
civilytics_logo()
```
}
\examples{
\dontrun{
library(ggplot2); library(grid)
# Pipe usage — parentheses required around the ggplot chain
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics()) |>
civilytics_logo() |>
grid.draw()
# Top-right placement
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics()) |>
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()
}
}