52 changed files with 344 additions and 2373 deletions

No files matched your search

+1 -1
View File
@@ -3,9 +3,9 @@
^\.github$ ^\.github$
^\.gitea$ ^\.gitea$
^README\.Rmd$ ^README\.Rmd$
^NEWS\.md$
^Makefile$ ^Makefile$
^Dockerfile$ ^Dockerfile$
^LICENSE\.md$
^\.claude$ ^\.claude$
^\.playwright-mcp$ ^\.playwright-mcp$
^civilytics-site\.png$ ^civilytics-site\.png$
View File
Whitespace-only changes.
+2 -2
View File
@@ -2,9 +2,9 @@ name: R-CMD-check
on: on:
push: push:
branches: [main] branches: [master]
pull_request: pull_request:
branches: [main] branches: [master]
jobs: jobs:
check: check:
-7
View File
@@ -2,10 +2,3 @@
.Rhistory .Rhistory
.RData .RData
.Ruserdata .Ruserdata
.compass-cache/
# roborev snapshots
/.roborev/
# Test run debris
tests/testthat/Rplots.pdf
tests/testthat/_problems/
-64
View File
@@ -1,64 +0,0 @@
# roborev configuration, initialised by compass.
# Reviews are queued to a background daemon -- they never block a commit.
post_commit_review = 'commit'
# Scoped conventional commits (`chore(packaging):`) do not contain `chore:`,
# and this repo's cadence rule mandates the scope -- so both forms are listed.
excluded_commit_patterns = ['WIP', 'chore:', 'chore(', 'docs:', 'docs(', 'Merge ']
review_guidelines = '''
# --- compass:begin (generated -- edit the sources, not this) ---
- Prefer returning new values to mutating arguments in place. A function that edits
its caller's object is a bug waiting for a second caller.
- Validate at system boundaries -- user input, API responses, file contents, config.
Fail fast with a message naming the field and the file.
- Never swallow an error. Handle it or let it propagate; a bare catch that continues
is worse than a crash.
- No hardcoded secrets, tokens, or credentials, and no secrets in log output or error
messages.
- Parameterise every query. String-built SQL is a defect even when the input looks safe.
- Keep functions under roughly 50 lines and files under roughly 400. Flag nesting
deeper than four levels.
- No magic numbers or hardcoded paths -- name them as constants or read them from config.
- New behaviour needs a test. A bug fix needs a test that fails without the fix.
- Prose a person reads -- an issue title or body, a journal entry, a decision record,
the narrative on the status board -- names the action or the thing, not the shape of
the machinery. Flag "gate", "seam", "surface area", "load-bearing", "first-class",
"primitive", "blast radius". A project's own defined vocabulary is not the target.
- Use the native pipe `|>`, not magrittr `%>%`.
- snake_case for objects and functions; UPPER_SNAKE for constants. Never use `.` as a
word separator in a function name -- it collides with S3 dispatch.
- Validate arguments at the top of exported functions with `stopifnot()` or an explicit
check, and say which argument was wrong.
- Never `setDT()`, `set()`, or otherwise modify by reference a data.table the caller
still owns. `as.data.table()` copies; use it.
- Prefer `vapply()` to `sapply()` -- `sapply()` silently returns a list when the type
varies, which turns a type error into a downstream mystery.
- Use `seq_len(n)` / `seq_along(x)`, never `1:n`, which iterates backwards when n is 0.
- Compare strings with `==` only after checking for NA; use `identical()` for scalars
where NA would be wrong.
- Do not call `library()` inside package or module files; attach packages in scripts and
test helpers only.
- Namespace-qualify calls into other packages (`stats::sd`) in code that is sourced.
- Every exported function needs roxygen with `@param` for each argument (type, meaning,
and why the default is what it is) and `@return`. Add `@examples` for exported API.
- Declare dependencies in DESCRIPTION. Prefer base R or an existing dependency over
adding a new one; a package with zero hard deps is worth keeping that way.
- Signal errors with `stop()` carrying a condition class, so callers can catch the kind
rather than matching on message text.
- Keep internals internal. Export only what a user needs; an accidentally exported
helper becomes an API you have to keep.
- Tests use testthat edition 3. Each test is self-sufficient -- no reliance on state
left by an earlier test or on a fixture built elsewhere in the file.
- Prefer duplication in tests over a helper that hides what is being asserted.
- Brand colors come from `civilytics_colors`; never write a hex literal in theme, scale, logo, or table code.
- No tidyverse dependency. Imports is base R plus ggplot2, grid/gridExtra, png/jpeg, stringr, stringdist, showtext/sysfonts, jsonlite. Reject dplyr, purrr, magrittr, tibble, and data.table; use base R idioms.
- NAMESPACE is roxygen-generated. Declare imports with `@importFrom` in the roxygen block and re-run roxygen; never hand-edit NAMESPACE.
- Themes default to a transparent background (`paper_bg = FALSE`) so plots composite onto any Quarto, Reveal, or Typst background. Making an opaque background the default is a regression, not a preference.
- Theme functions thread `ink`/`paper`/`accent` into ggplot2 4.0's base-theme parameters rather than setting element colors ad hoc. ggplot2 >= 4.0 is a hard dependency, so use S7 `@` property access on plot and theme objects, not `$`.
- User-facing progress goes through `message()` so callers can suppress it. No `cat()` or `print()` in package code.
- Nothing personal or client-identifying is vendored into `inst/` -- brand assets only. Version 0.3.2 removed headshots for exactly this reason.
- The camelCase exports (`countCleanr`, `dbSafeNames`, `simpleCap`, `waldInterval`, `countDots`, `countNA`, `findDots`, `nvals`) are frozen public API; do not rename them. New functions are snake_case.
- `R/theme.R` and `R/logo.R` are long by design -- one file per surface, with dense roxygen. File length is not a finding in this package; flag a single function over roughly 80 lines instead.
# --- compass:end ---
'''
-92
View File
@@ -1,92 +0,0 @@
# AGENTS.md
`civilytics` is the house R package for Civilytics Consulting: a ggplot2 brand theme
system, curated palettes, logo composition, Quarto/Typst/Reveal templates, and
data-wrangling helpers for public-sector analysis. It is a library other projects
depend on, so a breaking change here breaks reports that are already published.
## Project tracking
This repo is managed with compass. `pm/compass.toml`
defines the workstreams; `pm/JOURNAL.md` records sessions; `pm/decisions/` holds
numbered, immutable decision records. Ask compass where things stand rather than
reading the config back.
Workstreams (the `ws/` label on every issue):
| `ws/` | covers |
|---|---|
| `theme` | `R/theme.R`, `R/colors.R`, `R/fonts.R` — themes, palettes, font loading |
| `logo` | `R/logo.R`, `R/flextable.R`, `inst/img/` — logo and branded output |
| `quarto` | `R/quarto.R`, `inst/quarto/` — HTML, PDF, Typst, Reveal templates |
| `helpers` | `R/utils.R`, `R/prop_conf.R`, `R/join_utilities.R`, `R/db.R`, `R/notifications.R` |
| `packaging` | `DESCRIPTION`, `NAMESPACE`, `Makefile`, `Dockerfile`, `.gitea/workflows/` |
## Commit cadence
One coherent unit per commit, subject line:
```
type(ws): subject (#N)
```
`type` is one of `feat`, `fix`, `refactor`, `docs`, `test`, `chore`, `perf`, `ci`.
`ws` is a workstream id from the table above. `#N` is the issue, when there is one.
## Conventions
`pm/compass.toml` is authoritative for these rules. Its `[roborev]
project_guidelines` are composed into `.roborev.toml`, so change them there and
re-run compass rather than editing `.roborev.toml` by hand. The prose below is the
same rules stated for a human reader; if the two ever disagree, `pm/compass.toml`
wins.
**Dependencies.** Base R plus ggplot2 (>= 4.0), grid/gridExtra, png/jpeg, stringr,
stringdist, showtext/sysfonts, jsonlite. No tidyverse: no dplyr, purrr, magrittr,
tibble, or data.table. Prefer an existing dependency or base R over adding one —
this package is installed into other people's environments.
**Brand colors** live in `civilytics_colors` and nowhere else. Never write a hex
literal in theme, scale, logo, or table code.
**Themes** default to a transparent background (`paper_bg = FALSE`) so plots
composite onto any Quarto, Reveal, or Typst background. Thread `ink`, `paper`, and
`accent` into ggplot2 4.0's base-theme parameters rather than setting element colors
one at a time. ggplot2 >= 4.0 is a hard dependency, so use S7 `@` property access on
plot and theme objects, not `$`.
**Naming.** New functions are snake_case. The camelCase exports (`countCleanr`,
`dbSafeNames`, `simpleCap`, `waldInterval`, `countDots`, `countNA`, `findDots`,
`nvals`) are frozen public API — do not rename them.
**Documentation.** Roxygen generates both `man/` and `NAMESPACE`. Declare imports
with `@importFrom` in the roxygen block; never hand-edit `NAMESPACE`. Every exported
function needs `@param` for each argument and `@return`; exported API needs
`@examples`. Re-run roxygen in the same commit as the code change — compass files
documentation debt when code moves and its `man/` pages do not.
**Output.** User-facing progress goes through `message()` so callers can suppress it.
No `cat()` or `print()` in package code.
**Assets.** Nothing personal or client-identifying is vendored into `inst/` — brand
assets only. Version 0.3.2 removed headshots for exactly this reason.
## Testing
testthat edition 3, one file per source file (`tests/testthat/test_theme.R` etc.).
Tests are self-sufficient: no reliance on state left by an earlier test. New
behaviour needs a test; a bug fix needs a test that fails without the fix.
```zsh
make check # R CMD check --no-manual against a built tarball
Rscript -e 'devtools::test()'
```
CI runs `R CMD check` on `rocker/r-ver:4.6` via `.gitea/workflows/check.yaml` for
every push and PR to `main`.
## Release
Bump `Version` in `DESCRIPTION` and add a `NEWS.md` entry under **New features**,
**Bug fixes**, or **Internal**. `NEWS.md` is the changelog; compass tracks the work
that led to it, not the release itself.
-1
View File
@@ -1 +0,0 @@
@AGENTS.md
+2 -4
View File
@@ -1,7 +1,7 @@
Package: civilytics Package: civilytics
Type: Package Type: Package
Title: Brand Themes, Color Palettes, and Utility Functions for Civilytics Title: Brand Themes, Color Palettes, and Utility Functions for Civilytics
Version: 0.3.2 Version: 0.2.0
Authors@R: Authors@R:
person("Jared", "E. Knowles", email = "jared@civilytics.com", person("Jared", "E. Knowles", email = "jared@civilytics.com",
role = c("aut", "cre")) role = c("aut", "cre"))
@@ -34,9 +34,7 @@ Suggests:
quarto, quarto,
flextable, flextable,
officer, officer,
patchwork, ragg
ragg,
withr
Config/testthat/edition: 3 Config/testthat/edition: 3
Config/roxygen2/version: 8.0.0 Config/roxygen2/version: 8.0.0
RoxygenNote: 7.3.3 RoxygenNote: 7.3.3
View File
File renamed without changes.
-46
View File
@@ -1,46 +0,0 @@
# civilytics 0.3.2
## New features
- `civilytics_logo()` and `add_logo()` gain `logo_height` (inches, default `0.5`),
the height of a band reserved for the logo.
- `civilytics_load_fonts()` gains `showtext` (default `getOption("civilytics.showtext", TRUE)`), so ragg
users can register the brand fonts without turning on showtext, which draws text
at a third of its size on a 300 dpi ragg device. The default is unchanged (#29).
- `patchwork` is now a suggested package, used when a patchwork composition is
passed to `civilytics_logo()`.
- Added comprehensive test coverage for the `prop_conf` module, including
correctness checks against `binom.test()` for Clopper-Pearson intervals and
formula-based verification for Wald and Agresti-Coull intervals.
## Bug fixes
- `civilytics_logo()` / `add_logo()` now render every panel and the
`plot_annotation()` of a patchwork composition. They previously drew only the
last panel (#20).
- The logo now sits in its own reserved band instead of pulling the plot down with
negative margins, so captions are no longer clipped at the bottom edge and the
layout no longer depends on whether showtext is active (#20).
- `add_logo_ga()` gets the same reserved logo band (`logo_height`) and no longer
pulls the plots down with a negative margin. `margin_param` still overrides the
bottom margin when given (#28).
- The logo keeps its own aspect ratio on any canvas. `make_logo_grob()` used to
stretch it to a fixed fraction of the plot width, so its shape changed with
the canvas and it was already about 1.5 times too wide at 11 by 7 inches (#20).
- `font_scale` now defaults to `1` in `civilytics_logo()`, `add_logo()` and
`add_logo_ga()`. The old default of `1.1` enlarged the base text by 10% whenever
a logo was added. Pass `font_scale = 1.1` to keep the old sizes (#20).
- `style_flextable_civilytics()` defaults now come from `civilytics_colors`
instead of Bootstrap hex values: header `navy_700`, zebra `paper_2`, outer
border `rule_strong`, inner border `rule`, footer text `ink_3`. Tables built
with the defaults change appearance (#21).
- `civilytics-reveal`: PDF output keeps slide margins, ordered-list numbers no
longer clip at the left edge, and Quarto column widths (`.column width="60%"`)
are honored. Columns without a width stay equal, and the default gap is now
`1.5em` (#25, #26, #27).
- Removed vendored headshot images (`Knowles_Headshot_2019_good.jpg`,
`Knowles_Headshot_2019_prisma.jpg`) from `inst/img/` to prevent personal
photos from being distributed with the package. The `plot_jpeg()` example
now references a generic placeholder path instead of a specific headshot.
## Internal
- Renamed `LICENSE.md` to `LICENSE` for R packaging convention compliance so
that the LGPL-3 license ships correctly with built tarballs.
+7 -7
View File
@@ -199,7 +199,7 @@ civilytics_palette <- function(name = "qual", n = NULL, reverse = FALSE) {
#' Civilytics palette function (closure) #' Civilytics palette function (closure)
#' #'
#' Returns a closure `function(n)` suitable for passing to #' Returns a closure `function(n)` suitable for passing to
#' [discrete_scale()] or similar scale constructors. #' [ggplot2::discrete_scale()] or similar scale constructors.
#' #'
#' @param name Character. Palette name. See `names(civilytics_palettes)`. #' @param name Character. Palette name. See `names(civilytics_palettes)`.
#' @param reverse Logical. Reverse the palette order. Default `FALSE`. #' @param reverse Logical. Reverse the palette order. Default `FALSE`.
@@ -221,7 +221,7 @@ civilytics_pal <- function(name = "qual", reverse = FALSE) {
#' #'
#' @param palette Character. Palette name. Defaults to `"qual"`. #' @param palette Character. Palette name. Defaults to `"qual"`.
#' @param discrete Logical. `TRUE` (default) for categorical data; `FALSE` #' @param discrete Logical. `TRUE` (default) for categorical data; `FALSE`
#' for a continuous gradient via [scale_color_gradientn()]. #' for a continuous gradient via [ggplot2::scale_color_gradientn()].
#' @param reverse Logical. Reverse the palette order. Default `FALSE`. #' @param reverse Logical. Reverse the palette order. Default `FALSE`.
#' @param ... Additional arguments passed to the ggplot2 scale function. #' @param ... Additional arguments passed to the ggplot2 scale function.
#' #'
@@ -240,14 +240,14 @@ civilytics_pal <- function(name = "qual", reverse = FALSE) {
scale_color_civilytics <- function(palette = "qual", discrete = TRUE, scale_color_civilytics <- function(palette = "qual", discrete = TRUE,
reverse = FALSE, ...) { reverse = FALSE, ...) {
if (discrete) { if (discrete) {
discrete_scale( ggplot2::discrete_scale(
"colour", "colour",
palette = civilytics_pal(palette, reverse = reverse), palette = civilytics_pal(palette, reverse = reverse),
... ...
) )
} else { } else {
pal <- civilytics_palette(palette, reverse = reverse) pal <- civilytics_palette(palette, reverse = reverse)
scale_color_gradientn( ggplot2::scale_color_gradientn(
colours = grDevices::colorRampPalette(pal)(256), colours = grDevices::colorRampPalette(pal)(256),
... ...
) )
@@ -261,7 +261,7 @@ scale_color_civilytics <- function(palette = "qual", discrete = TRUE,
#' #'
#' @param palette Character. Palette name. Defaults to `"qual"`. #' @param palette Character. Palette name. Defaults to `"qual"`.
#' @param discrete Logical. `TRUE` (default) for categorical data; `FALSE` #' @param discrete Logical. `TRUE` (default) for categorical data; `FALSE`
#' for a continuous gradient via [scale_fill_gradientn()]. #' for a continuous gradient via [ggplot2::scale_fill_gradientn()].
#' @param reverse Logical. Reverse the palette order. Default `FALSE`. #' @param reverse Logical. Reverse the palette order. Default `FALSE`.
#' @param ... Additional arguments passed to the ggplot2 scale function. #' @param ... Additional arguments passed to the ggplot2 scale function.
#' #'
@@ -280,14 +280,14 @@ scale_color_civilytics <- function(palette = "qual", discrete = TRUE,
scale_fill_civilytics <- function(palette = "qual", discrete = TRUE, scale_fill_civilytics <- function(palette = "qual", discrete = TRUE,
reverse = FALSE, ...) { reverse = FALSE, ...) {
if (discrete) { if (discrete) {
discrete_scale( ggplot2::discrete_scale(
"fill", "fill",
palette = civilytics_pal(palette, reverse = reverse), palette = civilytics_pal(palette, reverse = reverse),
... ...
) )
} else { } else {
pal <- civilytics_palette(palette, reverse = reverse) pal <- civilytics_palette(palette, reverse = reverse)
scale_fill_gradientn( ggplot2::scale_fill_gradientn(
colours = grDevices::colorRampPalette(pal)(256), colours = grDevices::colorRampPalette(pal)(256),
... ...
) )
+4 -10
View File
@@ -19,7 +19,7 @@
#' @return a numeric column of data #' @return a numeric column of data
#' @export #' @export
countCleanr <- function(x){ countCleanr <- function(x){
if ("character" %in% class(x)) { if(class(x) == "character"){
x[x == "None not reported"] <- "0" x[x == "None not reported"] <- "0"
x[x == "Not applicable"] <- NA x[x == "Not applicable"] <- NA
x <- as.numeric(x) x <- as.numeric(x)
@@ -110,14 +110,8 @@ nvals <- function(x){
#' my_string <- c("Happy school", "Easy school", "cool School", "big school") #' my_string <- c("Happy school", "Easy school", "cool School", "big school")
#' simpleCap(my_string) #' simpleCap(my_string)
simpleCap <- function(x) { simpleCap <- function(x) {
stopifnot("character" %in% class(x)) stopifnot(class(x) == "character")
s <- strsplit(x, " ")[[1]]
# Vectorised over elements of x — each element is capitalised independently. paste(toupper(substring(s, 1,1)), substring(s, 2),
# unname() strips names inherited from the input vector so the output
# matches the original scalar behaviour (no names attribute).
unname(vapply(x, function(word) {
s <- strsplit(word, " ")[[1]]
paste(toupper(substring(s, 1, 1)), substring(s, 2),
sep = "", collapse = " ") sep = "", collapse = " ")
}, character(1)))
} }
+10 -12
View File
@@ -15,8 +15,7 @@
#' `flextable` is unavailable. #' `flextable` is unavailable.
#' #'
#' @param ft A [flextable::flextable()] object. #' @param ft A [flextable::flextable()] object.
#' @param header_bg Character. Header background fill. Default #' @param header_bg Character. Header background fill. Default `"#2c3e50"`.
#' `civilytics_colors[["navy_700"]]`.
#' @param header_color Character. Header text color. Default `"white"`. #' @param header_color Character. Header text color. Default `"white"`.
#' @param title_fontsize Numeric. Font size for the first header line (the #' @param title_fontsize Numeric. Font size for the first header line (the
#' title row, `i = 1`). Default `14`. #' title row, `i = 1`). Default `14`.
@@ -26,18 +25,17 @@
#' @param zebra Logical. Apply alternating-row striping to even body rows. #' @param zebra Logical. Apply alternating-row striping to even body rows.
#' Default `TRUE`. Safely skipped for tables with fewer than two body rows. #' Default `TRUE`. Safely skipped for tables with fewer than two body rows.
#' @param zebra_bg Character. Fill color for striped (even) body rows. #' @param zebra_bg Character. Fill color for striped (even) body rows.
#' Default `civilytics_colors[["paper_2"]]`. #' Default `"#f0f0eb"`.
#' @param outer_border_color Character. Outer border color. Default #' @param outer_border_color Character. Outer border color. Default
#' `civilytics_colors[["rule_strong"]]`. #' `"#888888"`.
#' @param outer_border_width Numeric. Outer border width. Default `1`. #' @param outer_border_width Numeric. Outer border width. Default `1`.
#' @param inner_border_color Character. Inner horizontal border color (body). #' @param inner_border_color Character. Inner horizontal border color (body).
#' Default `civilytics_colors[["rule"]]`. #' Default `"#cccccc"`.
#' @param inner_border_width Numeric. Inner horizontal border width. Default #' @param inner_border_width Numeric. Inner horizontal border width. Default
#' `0.5`. #' `0.5`.
#' @param footer_fontsize Numeric. Footer font size (applied only if a footer #' @param footer_fontsize Numeric. Footer font size (applied only if a footer
#' part exists). Default `9`. #' part exists). Default `9`.
#' @param footer_color Character. Footer text color. Default #' @param footer_color Character. Footer text color. Default `"#555555"`.
#' `civilytics_colors[["ink_3"]]`.
#' #'
#' @return The styled [flextable::flextable()] object. #' @return The styled [flextable::flextable()] object.
#' @export #' @export
@@ -52,19 +50,19 @@
#' style_flextable_civilytics() #' style_flextable_civilytics()
#' } #' }
style_flextable_civilytics <- function(ft, style_flextable_civilytics <- function(ft,
header_bg = civilytics_colors[["navy_700"]], header_bg = "#2c3e50",
header_color = "white", header_color = "white",
title_fontsize = 14, title_fontsize = 14,
body_fontsize = 11, body_fontsize = 11,
font_name = "Arial", font_name = "Arial",
zebra = TRUE, zebra = TRUE,
zebra_bg = civilytics_colors[["paper_2"]], zebra_bg = "#f0f0eb",
outer_border_color = civilytics_colors[["rule_strong"]], outer_border_color = "#888888",
outer_border_width = 1, outer_border_width = 1,
inner_border_color = civilytics_colors[["rule"]], inner_border_color = "#cccccc",
inner_border_width = 0.5, inner_border_width = 0.5,
footer_fontsize = 9, footer_fontsize = 9,
footer_color = civilytics_colors[["ink_3"]]) { footer_color = "#555555") {
if (!requireNamespace("flextable", quietly = TRUE)) { if (!requireNamespace("flextable", quietly = TRUE)) {
stop("Install 'flextable' to use this function.", call. = FALSE) stop("Install 'flextable' to use this function.", call. = FALSE)
} }
+12 -42
View File
@@ -5,62 +5,32 @@ CV_FONT_SANS <- "Inter" # axis text, legends, UI elements
CV_FONT_SERIF <- "Source Serif 4" # body prose / editorial long-form CV_FONT_SERIF <- "Source Serif 4" # body prose / editorial long-form
CV_FONT_MONO <- "JetBrains Mono" # code, data tables, numeric callouts CV_FONT_MONO <- "JetBrains Mono" # code, data tables, numeric callouts
# Mutable package state held in an environment so the binding itself stays # Internal flag so civilytics_load_fonts() is idempotent within a session.
# locked (R locks all namespace bindings at load time) while the contents .cv_fonts_loaded <- FALSE
# remain writable. See https://adv-r.hadley.nz/environments.html#environments-as-containers
.cv_state <- new.env(parent = emptyenv())
.cv_state$fonts_loaded <- FALSE
#' Load Civilytics brand fonts #' Load Civilytics brand fonts
#' #'
#' Downloads Inter, Libre Franklin, Source Serif 4 and JetBrains Mono from #' Downloads Inter and Libre Franklin from Google Fonts via
#' Google Fonts via [sysfonts::font_add_google()], then, unless #' [sysfonts::font_add_google()], then calls [showtext::showtext_auto()] so
#' `showtext = FALSE`, calls [showtext::showtext_auto()] so that all graphics #' that all graphics devices render text with those fonts. This is called
#' devices render text with those fonts. This is called automatically when the #' automatically when the package loads; use this function to retry if the
#' package loads; use this function to retry if the initial load failed (e.g., #' initial load failed (e.g., the machine was offline at load time).
#' the machine was offline at load time).
#' #'
#' Subsequent calls within the same session are no-ops unless `force = TRUE`. #' @return Invisibly returns `NULL`.
#'
#' **Using ragg.** [showtext::showtext_auto()] draws text at 96 dpi whatever the
#' device resolution, so on a `ragg::agg_png(res = 300)` device text comes out
#' at about a third of its requested size. For ragg, set
#' `options(civilytics.showtext = FALSE)` before loading the package, or call
#' `showtext::showtext_auto(FALSE)` afterwards. The brand fonts must then be
#' installed on the system, because ragg reads system fonts rather than the
#' ones registered through sysfonts.
#'
#' @param force Logical. If `TRUE`, reload fonts even if they were already
#' loaded in this session. Default `FALSE`.
#' @param showtext Logical. Turn on [showtext::showtext_auto()] after
#' registering the fonts. Default is `getOption("civilytics.showtext", TRUE)`.
#'
#' @return Invisibly returns `TRUE` if fonts were loaded, `FALSE` if skipped
#' (already loaded and `force = FALSE`).
#' @export #' @export
#' #'
#' @examples #' @examples
#' \dontrun{ #' \dontrun{
#' civilytics_load_fonts() #' civilytics_load_fonts()
#'
#' # For ragg devices: register the fonts but leave showtext off
#' civilytics_load_fonts(force = TRUE, showtext = FALSE)
#' } #' }
civilytics_load_fonts <- function(force = FALSE, civilytics_load_fonts <- function() {
showtext = getOption("civilytics.showtext", TRUE)) {
if (!is.logical(showtext) || length(showtext) != 1L || is.na(showtext)) {
stop("`showtext` must be a single TRUE or FALSE.", call. = FALSE)
}
if (.cv_state$fonts_loaded && !force) return(invisible(FALSE))
sysfonts::font_add_google("Inter", family = "Inter") sysfonts::font_add_google("Inter", family = "Inter")
sysfonts::font_add_google("Libre Franklin", family = "Libre Franklin") sysfonts::font_add_google("Libre Franklin", family = "Libre Franklin")
sysfonts::font_add_google("Source Serif 4", family = "Source Serif 4") sysfonts::font_add_google("Source Serif 4", family = "Source Serif 4")
sysfonts::font_add_google("JetBrains Mono", family = "JetBrains Mono") sysfonts::font_add_google("JetBrains Mono", family = "JetBrains Mono")
if (showtext) showtext::showtext_auto() showtext::showtext_auto()
.cv_fonts_loaded <<- TRUE
.cv_state$fonts_loaded <- TRUE invisible(NULL)
invisible(TRUE)
} }
.onLoad <- function(libname, pkgname) { .onLoad <- function(libname, pkgname) {
+22 -26
View File
@@ -1,14 +1,11 @@
# Join utilities # Join utilities
#' Test the join between two sets of identifiers #' Test the join between two sets of identifiers
#' #'
#' @param x A vector of identifiers to check against `y`. #' @param x a vector of identifiers to check against y
#' @param y A vector of identifiers to look for a match in. #' @param y a vector of identifiers to check against x
#' @param distinct Logical. Should duplicate values of `x` and `y` be removed #' @param distinct logical, should duplicate values of x and y be removed before testing
#' before testing? Default is `TRUE`.
#' #'
#' @return Invisibly returns `NULL`; prints a formatted summary of match #' @return nothing, print a summary of match statistics to the console
#' statistics to the console via [writeLines()].
#' @export #' @export
#' #'
#' @examples #' @examples
@@ -19,34 +16,33 @@ match_test <- function(x, y, distinct = TRUE) {
if (distinct) { if (distinct) {
x <- unique(x) x <- unique(x)
y <- unique(y) y <- unique(y)
cat("**** Distinct Matches ****")
cat("\n")
} }
# TODO: DO not report 100% if there is even 1 mismatch # TODO: DO not report 100% if there is even 1 mismatch
xiny <- sum(x %in% y) xiny <- sum(x %in% y)
total_x <- length(x) total_x <- length(x)
pct_x <- round(100 * xiny / total_x, 2)
yinx <- sum(y %in% x) yinx <- sum(y %in% x)
total_y <- length(y) total_y <- length(y)
pct_y <- round(100 * yinx / total_y, 2)
header <- if (distinct) "Distinct Matches" else "All Values" cat("**** Match Summary ****")
cat("\n")
cat("X in Y")
cat("\n")
cat(paste0("Of the ", total_x, " X values, ", xiny, " (",
100*round(xiny/total_x, 2), "%) were matched."))
cat("\n")
cat("********************************************")
cat("\n")
cat("Y in X")
cat("\n")
cat(paste0("Of the ", total_y, " Y values, ", yinx, " (",
100*round(yinx/total_y, 2), "%) were matched."))
cat("\n")
cat("******************************************")
lines <- c(
paste0("**** ", header, " ****"),
"",
"X in Y",
sprintf("Of the %d X values, %d (%s%%) were matched.",
total_x, xiny, format(pct_x, nsmall = 2)),
strrep("*", 40),
"",
"Y in X",
sprintf("Of the %d Y values, %d (%s%%) were matched.",
total_y, yinx, format(pct_y, nsmall = 2)),
strrep("*", 38)
)
writeLines(lines)
invisible(NULL)
} }
+73 -80
View File
@@ -10,8 +10,7 @@
#' @importFrom graphics rasterImage #' @importFrom graphics rasterImage
#' @examples #' @examples
#' \dontrun{ #' \dontrun{
#' # Supply a path to your own JPEG file #' img <- system.file("img","Knowles_Headshot_2019_good.jpg",package="civilytics")
#' img <- "my_photo.jpg"
#' plot_jpeg(img) #' plot_jpeg(img)
#' } #' }
plot_jpeg <- function(path, add=FALSE, upscale = TRUE) plot_jpeg <- function(path, add=FALSE, upscale = TRUE)
@@ -44,67 +43,65 @@ get_png <- function(filename) {
#' Add a logo to a ggplot2 object #' Add a logo to a ggplot2 object
#' #'
#' The logo gets its own band of reserved height (`logo_height`, in inches) #' @param plot a ggplot2 grob
#' below or above the plot, so it cannot overlap the plot's caption or push
#' anything off the canvas. Patchwork compositions are converted with
#' [patchwork::patchworkGrob()] so every panel and the
#' [patchwork::plot_annotation()] survive.
#'
#' @param plot a ggplot2 object, or a patchwork composition
#' @param logo a logo grob created by make_logo_grob() #' @param logo a logo grob created by make_logo_grob()
#' @param margin_param Optional numeric. Replaces the plot margin (in points) #' @param margin_param a numeric specifying what margin to add or subtract to align the logo
#' on the side next to the logo. `NULL` (default) leaves the plot's margins #' @param font_scale Numeric. Multiplicative scaling factor applied to text
#' alone. #' sizes before composing the plot with the logo. Default `1.1` inflates
#' @param font_scale Numeric. Multiplicative scaling factor applied to the #' text by ~10 \% to compensate for the viewport shrinkage caused by
#' base text size before composing. Default `1` leaves typography unchanged. #' [gridExtra::arrangeGrob()]. Set to `1` to disable.
#' @param position Character. Corner placement for the logo: `"bottom-right"` #' @param position Character. Corner placement for the logo: `"bottom-right"`
#' (default), `"bottom-left"`, `"top-right"`, or `"top-left"`. Controls #' (default), `"bottom-left"`, `"top-right"`, or `"top-left"`. Controls
#' whether the logo is placed above or below the plot. #' whether the logo is placed above or below the plot.
#' @param logo_height Numeric. Height in inches of the band reserved for the
#' logo. Default `0.5`.
#' #'
#' @return a grob with a logo attached to it ready to plot #' @return a grob with a logo attached to it ready to plot
#' @importFrom ggplot2 theme #' @importFrom ggplot2 theme
#' @importFrom gridExtra arrangeGrob #' @importFrom gridExtra arrangeGrob
#' @export #' @export
add_logo <- function(plot, logo, margin_param = NULL, font_scale = 1, add_logo <- function(plot, logo, margin_param = NULL, font_scale = 1.1,
position = c("bottom-right", "bottom-left", position = c("bottom-right", "bottom-left",
"top-right", "top-left"), "top-right", "top-left")) {
logo_height = 0.5) {
position <- match.arg(position) position <- match.arg(position)
at_top <- grepl("top", position) at_top <- grepl("top", position)
is_patchwork <- inherits(plot, "patchwork")
# Capture the plot's background color so we can fill the entire composed # Capture the plot's background color so we can fill the entire composed
# grob with it. The logo grob stays transparent (theme_void). # grob with it. The logo grob must stay transparent (theme_void) so that
# caption/axis text overlapping via negative margins remains visible.
bg_fill <- plot$theme$plot.background$fill bg_fill <- plot$theme$plot.background$fill
# Inflate text sizes to compensate for arrangeGrob viewport shrinkage.
# All theme text elements use rel() sizing, so scaling the root 'text'
# element cascades to titles, axis labels, legends, captions, and strips.
if (!is.null(font_scale) && font_scale != 1) { if (!is.null(font_scale) && font_scale != 1) {
base_size <- plot$theme$text$size base_size <- plot$theme$text$size %||% 14
if (is.null(base_size)) base_size <- 14 plot <- plot + ggplot2::theme(
scaled <- theme(text = ggplot2::element_text(size = base_size * font_scale)) text = ggplot2::element_text(size = base_size * font_scale)
plot <- if (is_patchwork) plot & scaled else plot + scaled )
} }
if (at_top) {
# For top placement, tighten the top margin of the plot
if (!is.null(margin_param)) { if (!is.null(margin_param)) {
side <- if (at_top) c(margin_param, 7, 7, 7) else c(7, 7, margin_param, 7) plot <- plot + theme(plot.margin = unit(c(margin_param, 7, 7, 7), "pt"))
margin <- theme(plot.margin = grid::unit(side, "pt"))
plot <- if (is_patchwork) plot & margin else plot + margin
}
# ggplot_build() on a patchwork builds only its last panel, so convert it
# explicitly before handing it to arrangeGrob().
plot_grob <- if (is_patchwork) patchwork::patchworkGrob(plot) else plot
plot_height <- grid::unit(1, "null")
band_height <- grid::unit(logo_height, "in")
composed <- if (at_top) {
arrangeGrob(logo, plot_grob, heights = grid::unit.c(band_height, plot_height),
padding = grid::unit(0.1, "line"))
} else { } else {
arrangeGrob(plot_grob, logo, plot <- plot + theme(plot.margin = unit(c(-14, 7, 7, 7), "pt"))
heights = grid::unit.c(plot_height, band_height), }
padding = grid::unit(0.1, "line")) composed <- arrangeGrob(logo, plot, heights = c(0.1, 0.93),
padding = unit(0.1, "line"))
} else {
# Bottom placement (original behaviour)
if(has_caption(plot)) {
cap_lines <- measure_caption(plot)
if (!is.null(margin_param)) {
plot <- plot + theme(plot.margin = unit(c(7, 7, margin_param, 7), "pt"))
} else {
plot <- plot + theme(plot.margin = unit(c(7, 7, cap_lines * -52, 7), "pt"))
}
} else {
plot <- plot + theme(plot.margin = unit(c(7, 7, -14, 7), "pt"))
}
composed <- arrangeGrob(plot, logo, heights = c(0.93, 0.1),
padding = unit(0.1, "line"))
} }
# Wrap with a full-bleed background rect so any transparent areas (the # Wrap with a full-bleed background rect so any transparent areas (the
@@ -128,7 +125,7 @@ add_logo <- function(plot, logo, margin_param = NULL, font_scale = 1,
#' @export #' @export
#' #'
#' @examples #' @examples
#' p1 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() #' p1 <- ggplot2::ggplot(mtcars, ggplot2::aes(mpg, wt)) + ggplot2::geom_point()
#' measure_caption(p1) # Should equal 1 since no caption is present #' measure_caption(p1) # Should equal 1 since no caption is present
measure_caption <- function(gg) { measure_caption <- function(gg) {
if (has_caption(gg)) { if (has_caption(gg)) {
@@ -148,7 +145,7 @@ measure_caption <- function(gg) {
#' @export #' @export
#' #'
#' @examples #' @examples
#' p1 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() #' p1 <- ggplot2::ggplot(mtcars, ggplot2::aes(mpg, wt)) + ggplot2::geom_point()
#' has_caption(p1) # FALSE #' has_caption(p1) # FALSE
has_caption <- function(gg) { has_caption <- function(gg) {
any(names(gg$labels) == "caption") any(names(gg$labels) == "caption")
@@ -160,12 +157,9 @@ has_caption <- function(gg) {
#' @param logo a grob containing the logo created with `make_logo_grob` #' @param logo a grob containing the logo created with `make_logo_grob`
#' @param nrow an integer, default = 1, for the number of rows to align the plots in #' @param nrow an integer, default = 1, for the number of rows to align the plots in
#' @param widths an optional vector the same length as plot_list with the widths for each plot #' @param widths an optional vector the same length as plot_list with the widths for each plot
#' @param margin_param Optional number. Replaces the bottom plot margin (in points). #' @param margin_param a number giving the adjustment up or down to help manually align logo and captions
#' `NULL` (default) leaves plot margins alone.
#' @param font_scale Numeric. Multiplicative scaling factor applied to text #' @param font_scale Numeric. Multiplicative scaling factor applied to text
#' sizes before composing. Default `1`. See [add_logo()] for details. #' sizes before composing. Default `1.1`. See [add_logo()] for details.
#' @param logo_height Numeric. Height in inches of the band reserved for the
#' logo below the plots. Default `0.5`.
#' #'
#' @return a grid object #' @return a grid object
#' @note The resulting object needs to be drawn to the screen using grid.draw() #' @note The resulting object needs to be drawn to the screen using grid.draw()
@@ -184,31 +178,35 @@ has_caption <- function(gg) {
#' dev.off() #' dev.off()
#' } #' }
add_logo_ga <- function(plot_list, logo, nrow = 1, widths = NULL, add_logo_ga <- function(plot_list, logo, nrow = 1, widths = NULL,
margin_param = NULL, font_scale = 1, margin_param = NULL, font_scale = 1.1) {
logo_height = 0.5) {
# Capture the background color from the first plot # Capture the background color from the first plot
bg_fill <- plot_list[[1]]$theme$plot.background$fill bg_fill <- plot_list[[1]]$theme$plot.background$fill
# Inflate text sizes to compensate for viewport shrinkage
if (!is.null(font_scale) && font_scale != 1) { if (!is.null(font_scale) && font_scale != 1) {
plot_list <- lapply(plot_list, function(p) { plot_list <- lapply(plot_list, function(p) {
base_size <- p$theme$text$size %||% 14 base_size <- p$theme$text$size %||% 14
p + theme( p + ggplot2::theme(
text = element_text(size = base_size * font_scale) text = ggplot2::element_text(size = base_size * font_scale)
) )
}) })
} }
# The logo has its own band below the plots, so no margin adjustment is # Change position of logo depending on if plot has a caption
# needed. `margin_param` still replaces the bottom margin when given.
if (!is.null(margin_param)) { if (!is.null(margin_param)) {
margin <- theme(plot.margin = unit(c(7, 7, margin_param, 7), "pt")) margin <- theme(plot.margin = unit(c(7, 7, margin_param, 7), "pt"))
} else if (any(unlist(lapply(plot_list, has_caption)))) {
cap_lines <- max(sapply(plot_list, measure_caption))
margin <- theme(plot.margin = unit(c(7, 7, -7 * sqrt(cap_lines), 7), "pt"))
} else {
margin <- theme(plot.margin = unit(c(7, 7, 7, 7), "pt"))
}
if (nrow > 1) { if (nrow > 1) {
len <- length(plot_list) len <- length(plot_list)
plot_list[[len]] <- plot_list[[len]] + margin plot_list[[len]] <- plot_list[[len]] + margin
} else { } else {
plot_list <- lapply(plot_list, "+", margin) plot_list <- lapply(plot_list, "+", margin)
} }
}
if (nrow != 1) { if (nrow != 1) {
if (!is.null(widths)) warning("`widths` is ignored when `nrow > 1`") if (!is.null(widths)) warning("`widths` is ignored when `nrow > 1`")
@@ -217,10 +215,7 @@ add_logo_ga <- function(plot_list, logo, nrow = 1, widths = NULL,
hold <- arrangeGrob(grobs = plot_list, nrow = 1, ncol = length(plot_list), widths = widths) hold <- arrangeGrob(grobs = plot_list, nrow = 1, ncol = length(plot_list), widths = widths)
} }
composed <- arrangeGrob( composed <- arrangeGrob(hold, logo, heights = c(0.93, .07))
hold, logo,
heights = grid::unit.c(grid::unit(1, "null"), grid::unit(logo_height, "in"))
)
if (!is.null(bg_fill) && !is.na(bg_fill)) { if (!is.null(bg_fill) && !is.na(bg_fill)) {
bg_rect <- grid::rectGrob(gp = grid::gpar(fill = bg_fill, col = NA)) bg_rect <- grid::rectGrob(gp = grid::gpar(fill = bg_fill, col = NA))
@@ -272,20 +267,20 @@ make_logo_grob <- function(type = c("wordmark", "mark"),
align_left <- grepl("left", position) align_left <- grepl("left", position)
# Give the raster a height only, so grid derives its width from the image's if (align_left) {
# own aspect ratio, then pin it to the corner. The logo is the same shape on xmin <- 0
# any canvas width. xmax <- if (type == "mark") 0.07 else 0.35
logo <- grid::rasterGrob( } else {
png::readPNG(system.file("img", img_file, package = "civilytics")), xmin <- if (type == "mark") 0.93 else 0.65
x = if (align_left) grid::unit(7, "pt") else grid::unit(1, "npc") - grid::unit(7, "pt"), xmax <- 1
just = if (align_left) "left" else "right", }
height = grid::unit(1, "npc"),
interpolate = TRUE
)
ggplot() + ggplot2::ggplot() +
theme_void() + ggplot2::theme_void() +
annotation_custom(logo, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf) ggplot2::annotation_custom(
get_png(system.file("img", img_file, package = "civilytics")),
xmin = xmin, xmax = xmax
)
} }
#' Add a Civilytics logo to a ggplot (pipe-friendly) #' Add a Civilytics logo to a ggplot (pipe-friendly)
@@ -312,10 +307,9 @@ make_logo_grob <- function(type = c("wordmark", "mark"),
#' (default), `"bottom-left"`, `"top-right"`, or `"top-left"`. #' (default), `"bottom-left"`, `"top-right"`, or `"top-left"`.
#' @param margin_param Numeric or `NULL`. Manual margin adjustment passed to #' @param margin_param Numeric or `NULL`. Manual margin adjustment passed to
#' [add_logo()]. #' [add_logo()].
#' @param font_scale Numeric. Multiplies the plot's base text size before #' @param font_scale Numeric. Inflate text sizes by this factor to compensate
#' composing. Default `1` leaves typography unchanged. #' for viewport shrinkage when composing with [gridExtra::arrangeGrob()].
#' @param logo_height Numeric. Height in inches of the band reserved for the #' Default `1.1` (~10 \% inflation). Set to `1` to disable.
#' logo. Default `0.5`.
#' #'
#' @return A grob (from [gridExtra::arrangeGrob()]) ready to draw with #' @return A grob (from [gridExtra::arrangeGrob()]) ready to draw with
#' [grid::grid.draw()]. #' [grid::grid.draw()].
@@ -360,12 +354,11 @@ civilytics_logo <- function(plot,
position = c("bottom-right", "bottom-left", position = c("bottom-right", "bottom-left",
"top-right", "top-left"), "top-right", "top-left"),
margin_param = NULL, margin_param = NULL,
font_scale = 1, font_scale = 1.1) {
logo_height = 0.5) {
position <- match.arg(position) position <- match.arg(position)
logo <- make_logo_grob(type = type, variant = variant, position = position) logo <- make_logo_grob(type = type, variant = variant, position = position)
add_logo(plot, logo, margin_param = margin_param, font_scale = font_scale, add_logo(plot, logo, margin_param = margin_param, font_scale = font_scale,
position = position, logo_height = logo_height) position = position)
} }
+7 -9
View File
@@ -135,12 +135,12 @@ use_civilytics_theme <- function(path = ".", force = FALSE) {
.copy_pkg_file(file.path("quarto/latex", f), file.path("latex", f), path, force) .copy_pkg_file(file.path("quarto/latex", f), file.path("latex", f), path, force)
} }
# Typst — shipped as template-partials so Quarto keeps its Skylighting # Typst
# definitions and syntax-highlighted code blocks render (see issue #12) .copy_pkg_file(
typst_files <- c("typst-template.typ", "typst-show.typ") "quarto/typst/civilytics-typst.typ",
for (f in typst_files) { "typst/civilytics-typst.typ",
.copy_pkg_file(file.path("quarto/typst", f), file.path("typst", f), path, force) path, force
} )
# Logos — for _brand.yml (expects assets/logo/) # Logos — for _brand.yml (expects assets/logo/)
.copy_logos("assets/logo", path, force) .copy_logos("assets/logo", path, force)
@@ -158,9 +158,7 @@ use_civilytics_theme <- function(path = ".", force = FALSE) {
message(" include-in-header: latex/civilytics.tex") message(" include-in-header: latex/civilytics.tex")
message(" include-before-body: latex/civilytics-title.tex") message(" include-before-body: latex/civilytics-title.tex")
message(" typst:") message(" typst:")
message(" template-partials:") message(" template: typst/civilytics-typst.typ")
message(" - typst/typst-template.typ")
message(" - typst/typst-show.typ")
message("---") message("---")
message("\nSee examples/report.qmd for a complete example.") message("\nSee examples/report.qmd for a complete example.")
invisible(NULL) invisible(NULL)
+110 -112
View File
@@ -1,6 +1,6 @@
#' Civilytics ggplot2 theme #' Civilytics ggplot2 theme
#' #'
#' A complete ggplot2 theme built on [theme_grey()] using the #' A complete ggplot2 theme built on [ggplot2::theme_grey()] using the
#' Civilytics brand color palette and typography. Requires ggplot2 >= 4.0.0 #' Civilytics brand color palette and typography. Requires ggplot2 >= 4.0.0
#' for the `ink`, `paper`, and `accent` base-theme parameters. #' for the `ink`, `paper`, and `accent` base-theme parameters.
#' #'
@@ -36,12 +36,10 @@
#' to [civilytics_colors]`["paper_2"]` (`#F2EDE4`). #' to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).
#' @param grid Character. Which major gridlines to draw: `"y"` (default, #' @param grid Character. Which major gridlines to draw: `"y"` (default,
#' horizontal only), `"x"` (vertical only), `"both"`, or `"none"`. #' horizontal only), `"x"` (vertical only), `"both"`, or `"none"`.
#' @param paper_bg Logical. If `TRUE`, fill the plot and panel backgrounds #' @param paper_bg Logical. If `TRUE` (default), fill the plot and panel
#' with the warm `paper` color (Civilytics cream). Default is `FALSE` #' backgrounds with the warm `paper` color. Set to `FALSE` for a
#' (transparent) so that figures composite cleanly onto any background. #' transparent background (useful for slides or overlay on colored
#' Set to `TRUE` for the branded cream canvas. Note: a transparent device #' surfaces).
#' background (e.g., `dev = "ragg_png"`, `dev.args = list(background =
#' "transparent")`) is also needed for fully-transparent PNG exports.
#' #'
#' @section Font size hierarchy: #' @section Font size hierarchy:
#' All text sizes are derived from `font_size` using relative scale factors. #' All text sizes are derived from `font_size` using relative scale factors.
@@ -63,14 +61,14 @@
#' logo below the plot, pass `font_scale` to compensate for viewport #' logo below the plot, pass `font_scale` to compensate for viewport
#' shrinkage. #' shrinkage.
#' #'
#' @return A complete ggplot2 [theme()] object. #' @return A complete ggplot2 [ggplot2::theme()] object.
#' @export #' @export
#' #'
#' @examples #' @examples
#' \dontrun{ #' \dontrun{
#' library(ggplot2) #' library(ggplot2)
#' #'
#' # Default — transparent background for embedding #' # Default editorial theme
#' ggplot(mpg, aes(displ, hwy)) + #' ggplot(mpg, aes(displ, hwy)) +
#' geom_point() + #' geom_point() +
#' theme_civilytics() #' theme_civilytics()
@@ -81,10 +79,10 @@
#' scale_color_civilytics() + #' scale_color_civilytics() +
#' theme_civilytics(grid = "both") #' theme_civilytics(grid = "both")
#' #'
#' # Branded cream background (opt-in) #' # Transparent background for embedding
#' ggplot(mpg, aes(displ, hwy)) + #' ggplot(mpg, aes(displ, hwy)) +
#' geom_point() + #' geom_point() +
#' theme_civilytics(paper_bg = TRUE) #' theme_civilytics(paper_bg = FALSE)
#' #'
#' # Larger text for poster or display #' # Larger text for poster or display
#' ggplot(mpg, aes(displ, hwy)) + #' ggplot(mpg, aes(displ, hwy)) +
@@ -104,7 +102,7 @@ theme_civilytics <- function(
accent = unname(civilytics_colors["ember_600"]), accent = unname(civilytics_colors["ember_600"]),
strip_color = unname(civilytics_colors["paper_2"]), strip_color = unname(civilytics_colors["paper_2"]),
grid = c("y", "x", "both", "none"), grid = c("y", "x", "both", "none"),
paper_bg = FALSE) { paper_bg = TRUE) {
grid <- match.arg(grid) grid <- match.arg(grid)
half_line <- font_size / 2 half_line <- font_size / 2
@@ -115,30 +113,30 @@ theme_civilytics <- function(
bg_color <- if (isTRUE(paper_bg)) paper else NA bg_color <- if (isTRUE(paper_bg)) paper else NA
# Grid line elements # Grid line elements
grid_line <- element_line(color = rule_color, linewidth = 0.35) grid_line <- ggplot2::element_line(color = rule_color, linewidth = 0.35)
no_line <- element_blank() no_line <- ggplot2::element_blank()
theme_grey( ggplot2::theme_grey(
base_size = font_size, base_size = font_size,
base_family = font_family, base_family = font_family,
ink = ink, ink = ink,
paper = paper, paper = paper,
accent = accent accent = accent
) %+replace% ) %+replace%
theme( ggplot2::theme(
line = element_line( line = ggplot2::element_line(
color = ink, color = ink,
linewidth = line_size, linewidth = line_size,
linetype = 1, linetype = 1,
lineend = "butt" lineend = "butt"
), ),
rect = element_rect( rect = ggplot2::element_rect(
fill = NA, fill = NA,
color = NA, color = NA,
linewidth = line_size, linewidth = line_size,
linetype = 1 linetype = 1
), ),
text = element_text( text = ggplot2::element_text(
family = font_family, family = font_family,
face = "plain", face = "plain",
color = ink, color = ink,
@@ -147,161 +145,161 @@ theme_civilytics <- function(
vjust = 0.5, vjust = 0.5,
angle = 0, angle = 0,
lineheight = 0.9, lineheight = 0.9,
margin = margin(), margin = ggplot2::margin(),
debug = FALSE debug = FALSE
), ),
# -- Axes -- # -- Axes --
axis.line = element_blank(), axis.line = ggplot2::element_blank(),
axis.line.x = element_line( axis.line.x = ggplot2::element_line(
color = ink, color = ink,
linewidth = 0.6, linewidth = 0.6,
lineend = "square" lineend = "square"
), ),
axis.line.y = element_blank(), axis.line.y = ggplot2::element_blank(),
axis.text = element_text( axis.text = ggplot2::element_text(
color = ink_2, color = ink_2,
size = rel(rel_small) size = ggplot2::rel(rel_small)
), ),
axis.text.x = element_text( axis.text.x = ggplot2::element_text(
margin = margin(t = small_size / 4), margin = ggplot2::margin(t = small_size / 4),
vjust = 1 vjust = 1
), ),
axis.text.x.top = element_text( axis.text.x.top = ggplot2::element_text(
margin = margin(b = small_size / 4), margin = ggplot2::margin(b = small_size / 4),
vjust = 0 vjust = 0
), ),
axis.text.y = element_text( axis.text.y = ggplot2::element_text(
margin = margin(r = small_size / 4), margin = ggplot2::margin(r = small_size / 4),
hjust = 1 hjust = 1
), ),
axis.text.y.right = element_text( axis.text.y.right = ggplot2::element_text(
margin = margin(l = small_size / 4), margin = ggplot2::margin(l = small_size / 4),
hjust = 0 hjust = 0
), ),
axis.ticks = element_line( axis.ticks = ggplot2::element_line(
color = ink_3, color = ink_3,
linewidth = 0.4 linewidth = 0.4
), ),
axis.ticks.length = unit(4, "pt"), axis.ticks.length = ggplot2::unit(4, "pt"),
axis.title.x = element_text( axis.title.x = ggplot2::element_text(
size = rel(rel_small), size = ggplot2::rel(rel_small),
color = ink_3, color = ink_3,
margin = margin(t = 10), margin = ggplot2::margin(t = 10),
vjust = 1 vjust = 1
), ),
axis.title.x.top = element_text( axis.title.x.top = ggplot2::element_text(
size = rel(rel_small), size = ggplot2::rel(rel_small),
color = ink_3, color = ink_3,
margin = margin(b = half_line / 2), margin = ggplot2::margin(b = half_line / 2),
vjust = 0 vjust = 0
), ),
axis.title.y = element_text( axis.title.y = ggplot2::element_text(
size = rel(rel_small), size = ggplot2::rel(rel_small),
color = ink_3, color = ink_3,
angle = 90, angle = 90,
margin = margin(r = 10), margin = ggplot2::margin(r = 10),
vjust = 1 vjust = 1
), ),
axis.title.y.right = element_text( axis.title.y.right = ggplot2::element_text(
size = rel(rel_small), size = ggplot2::rel(rel_small),
color = ink_3, color = ink_3,
angle = -90, angle = -90,
margin = margin(l = half_line / 2), margin = ggplot2::margin(l = half_line / 2),
vjust = 0 vjust = 0
), ),
# -- Legend -- # -- Legend --
legend.background = element_blank(), legend.background = ggplot2::element_blank(),
legend.spacing = unit(font_size, "pt"), legend.spacing = ggplot2::unit(font_size, "pt"),
legend.spacing.x = NULL, legend.spacing.x = NULL,
legend.spacing.y = NULL, legend.spacing.y = NULL,
legend.margin = margin(0, 0, 4, 0), legend.margin = ggplot2::margin(0, 0, 4, 0),
legend.key = element_blank(), legend.key = ggplot2::element_blank(),
legend.key.size = unit(12, "pt"), legend.key.size = ggplot2::unit(12, "pt"),
legend.key.height = NULL, legend.key.height = NULL,
legend.key.width = NULL, legend.key.width = NULL,
legend.text = element_text( legend.text = ggplot2::element_text(
size = rel(rel_small), size = ggplot2::rel(rel_small),
color = ink_2 color = ink_2
), ),
legend.title = element_text( legend.title = ggplot2::element_text(
hjust = 0, hjust = 0,
face = "bold", face = "bold",
size = rel(rel_tiny), size = ggplot2::rel(rel_tiny),
color = ink_3 color = ink_3
), ),
legend.position = "top", legend.position = "top",
legend.direction = NULL, legend.direction = NULL,
legend.justification = c("left", "center"), legend.justification = c("left", "center"),
legend.box = NULL, legend.box = NULL,
legend.box.margin = margin(0, 0, 0, 0), legend.box.margin = ggplot2::margin(0, 0, 0, 0),
legend.box.background = element_blank(), legend.box.background = ggplot2::element_blank(),
legend.box.spacing = unit(font_size, "pt"), legend.box.spacing = ggplot2::unit(font_size, "pt"),
# -- Panel -- # -- Panel --
panel.background = element_rect(fill = bg_color, color = NA), panel.background = ggplot2::element_rect(fill = bg_color, color = NA),
panel.border = element_blank(), panel.border = ggplot2::element_blank(),
panel.grid.minor = element_blank(), panel.grid.minor = ggplot2::element_blank(),
panel.grid.major.x = if (grid %in% c("x", "both")) grid_line else no_line, panel.grid.major.x = if (grid %in% c("x", "both")) grid_line else no_line,
panel.grid.major.y = if (grid %in% c("y", "both")) grid_line else no_line, panel.grid.major.y = if (grid %in% c("y", "both")) grid_line else no_line,
panel.spacing = unit(16, "pt"), panel.spacing = ggplot2::unit(16, "pt"),
panel.spacing.x = NULL, panel.spacing.x = NULL,
panel.spacing.y = NULL, panel.spacing.y = NULL,
panel.ontop = FALSE, panel.ontop = FALSE,
# -- Facet strips -- # -- Facet strips --
strip.background = element_rect(fill = strip_color, color = NA), strip.background = ggplot2::element_rect(fill = strip_color, color = NA),
strip.text = element_text( strip.text = ggplot2::element_text(
family = font_family, family = font_family,
face = "bold", face = "bold",
size = rel(rel_small), size = ggplot2::rel(rel_small),
color = ink, color = ink,
margin = margin( margin = ggplot2::margin(
half_line / 2, half_line / 2, half_line / 2, half_line / 2,
half_line / 2, half_line / 2 half_line / 2, half_line / 2
) )
), ),
strip.text.x = NULL, strip.text.x = NULL,
strip.text.y = element_text(angle = -90), strip.text.y = ggplot2::element_text(angle = -90),
strip.placement = "inside", strip.placement = "inside",
strip.placement.x = NULL, strip.placement.x = NULL,
strip.placement.y = NULL, strip.placement.y = NULL,
strip.switch.pad.grid = unit(half_line / 2, "pt"), strip.switch.pad.grid = ggplot2::unit(half_line / 2, "pt"),
strip.switch.pad.wrap = unit(half_line / 2, "pt"), strip.switch.pad.wrap = ggplot2::unit(half_line / 2, "pt"),
# -- Plot-level -- # -- Plot-level --
plot.background = element_rect(fill = bg_color, color = NA), plot.background = ggplot2::element_rect(fill = bg_color, color = NA),
plot.title = element_text( plot.title = ggplot2::element_text(
family = title_family, family = title_family,
face = "bold", face = "bold",
size = rel(rel_large), size = ggplot2::rel(rel_large),
hjust = 0, hjust = 0,
vjust = 1, vjust = 1,
margin = margin(b = 4) margin = ggplot2::margin(b = 4)
), ),
plot.title.position = "plot", plot.title.position = "plot",
plot.subtitle = element_text( plot.subtitle = ggplot2::element_text(
size = rel(1), size = ggplot2::rel(1),
color = ink_2, color = ink_2,
hjust = 0, hjust = 0,
vjust = 1, vjust = 1,
lineheight = 1.3, lineheight = 1.3,
margin = margin(b = 14) margin = ggplot2::margin(b = 14)
), ),
plot.caption = element_text( plot.caption = ggplot2::element_text(
size = rel(rel_tiny), size = ggplot2::rel(rel_tiny),
color = ink_3, color = ink_3,
hjust = 0, hjust = 0,
vjust = 1, vjust = 1,
lineheight = 1.3, lineheight = 1.3,
margin = margin(t = 14) margin = ggplot2::margin(t = 14)
), ),
plot.caption.position = "plot", plot.caption.position = "plot",
plot.tag = element_text( plot.tag = ggplot2::element_text(
face = "bold", face = "bold",
color = accent, color = accent,
size = rel(rel_tiny), size = ggplot2::rel(rel_tiny),
hjust = 0, hjust = 0,
vjust = 0.7 vjust = 0.7
), ),
plot.tag.position = c(0, 1), plot.tag.position = c(0, 1),
plot.margin = margin(16, 18, 16, 16), plot.margin = ggplot2::margin(16, 18, 16, 16),
complete = TRUE complete = TRUE
) )
} }
@@ -317,7 +315,7 @@ theme_civilytics <- function(
#' #'
#' @inheritParams theme_civilytics #' @inheritParams theme_civilytics
#' #'
#' @return A complete ggplot2 [theme()] object. #' @return A complete ggplot2 [ggplot2::theme()] object.
#' @export #' @export
#' #'
#' @examples #' @examples
@@ -361,20 +359,20 @@ theme_civilytics_dark <- function(
# The base theme hardcodes ink_2/ink_3 for subtitle/caption, which are # The base theme hardcodes ink_2/ink_3 for subtitle/caption, which are
# dark colors meant for light backgrounds. Override with lighter values # dark colors meant for light backgrounds. Override with lighter values
# so text remains readable on the navy background. # so text remains readable on the navy background.
theme( ggplot2::theme(
plot.subtitle = element_text( plot.subtitle = ggplot2::element_text(
color = unname(civilytics_colors["navy_200"]) color = unname(civilytics_colors["navy_200"])
), ),
plot.caption = element_text( plot.caption = ggplot2::element_text(
color = unname(civilytics_colors["navy_300"]) color = unname(civilytics_colors["navy_300"])
), ),
axis.text = element_text( axis.text = ggplot2::element_text(
color = unname(civilytics_colors["navy_200"]) color = unname(civilytics_colors["navy_200"])
), ),
axis.title.x = element_text( axis.title.x = ggplot2::element_text(
color = unname(civilytics_colors["navy_300"]) color = unname(civilytics_colors["navy_300"])
), ),
axis.title.y = element_text( axis.title.y = ggplot2::element_text(
color = unname(civilytics_colors["navy_300"]) color = unname(civilytics_colors["navy_300"])
) )
) )
@@ -389,7 +387,7 @@ theme_civilytics_dark <- function(
#' #'
#' @inheritParams theme_civilytics #' @inheritParams theme_civilytics
#' #'
#' @return A complete ggplot2 [theme()] object. #' @return A complete ggplot2 [ggplot2::theme()] object.
#' @export #' @export
#' #'
#' @examples #' @examples
@@ -430,13 +428,13 @@ theme_civilytics_slide <- function(
grid = grid, grid = grid,
paper_bg = paper_bg paper_bg = paper_bg
) + ) +
theme( ggplot2::theme(
axis.line.x = element_line( axis.line.x = ggplot2::element_line(
color = ink, color = ink,
linewidth = 0.8, linewidth = 0.8,
lineend = "square" lineend = "square"
), ),
plot.margin = margin(24, 24, 24, 24) plot.margin = ggplot2::margin(24, 24, 24, 24)
) )
} }
@@ -448,23 +446,23 @@ theme_civilytics_slide <- function(
#' Strips away axes, ticks, gridlines, and axis titles/labels — the elements #' Strips away axes, ticks, gridlines, and axis titles/labels — the elements
#' that are meaningless on a choropleth or spatial plot. #' that are meaningless on a choropleth or spatial plot.
#' #'
#' @return A partial ggplot2 [theme()] object. #' @return A partial ggplot2 [ggplot2::theme()] object.
#' @keywords internal #' @keywords internal
.map_theme_extras <- function() { .map_theme_extras <- function() {
theme( ggplot2::theme(
axis.line = element_blank(), axis.line = ggplot2::element_blank(),
axis.line.x = element_blank(), axis.line.x = ggplot2::element_blank(),
axis.line.y = element_blank(), axis.line.y = ggplot2::element_blank(),
axis.text = element_blank(), axis.text = ggplot2::element_blank(),
axis.text.x = element_blank(), axis.text.x = ggplot2::element_blank(),
axis.text.y = element_blank(), axis.text.y = ggplot2::element_blank(),
axis.ticks = element_blank(), axis.ticks = ggplot2::element_blank(),
axis.ticks.length = unit(0, "pt"), axis.ticks.length = ggplot2::unit(0, "pt"),
axis.title.x = element_blank(), axis.title.x = ggplot2::element_blank(),
axis.title.y = element_blank(), axis.title.y = ggplot2::element_blank(),
panel.grid.major.x = element_blank(), panel.grid.major.x = ggplot2::element_blank(),
panel.grid.major.y = element_blank(), panel.grid.major.y = ggplot2::element_blank(),
panel.grid.minor = element_blank() panel.grid.minor = ggplot2::element_blank()
) )
} }
@@ -478,7 +476,7 @@ theme_civilytics_slide <- function(
#' #'
#' @inheritParams theme_civilytics #' @inheritParams theme_civilytics
#' #'
#' @return A complete ggplot2 [theme()] object. #' @return A complete ggplot2 [ggplot2::theme()] object.
#' @export #' @export
#' #'
#' @examples #' @examples
@@ -530,7 +528,7 @@ theme_civilytics_map <- function(
#' #'
#' @inheritParams theme_civilytics_dark #' @inheritParams theme_civilytics_dark
#' #'
#' @return A complete ggplot2 [theme()] object. #' @return A complete ggplot2 [ggplot2::theme()] object.
#' @export #' @export
#' #'
#' @examples #' @examples
@@ -581,7 +579,7 @@ theme_civilytics_dark_map <- function(
#' #'
#' @inheritParams theme_civilytics_slide #' @inheritParams theme_civilytics_slide
#' #'
#' @return A complete ggplot2 [theme()] object. #' @return A complete ggplot2 [ggplot2::theme()] object.
#' @export #' @export
#' #'
#' @examples #' @examples
-866
View File
@@ -1,866 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
@font-face {
font-family: octicons-link;
src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcE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29KTQT48Ob9/lqYwOGZxeUelN2U2R6+cArgtCJpauW7UQBqnFkUsjAY/kOU1cP+DAgvxwn1chZDwUbd6CFimGXwzwF6tPbFIcjEl+vvmM/byA48e6tWrKArm4ZJlCbdsrxksL1AwWn/yBSJKpYbq8AXaaTb8AAHja28jAwOC00ZrBeQNDQOWO//sdBBgYGRiYWYAEELEwMTE4uzo5Zzo5b2BxdnFOcALxNjA6b2ByTswC8jYwg0VlNuoCTWAMqNzMzsoK1rEhNqByEyerg5PMJlYuVueETKcd/89uBpnpvIEVomeHLoMsAAe1Id4AAAAAAAB42oWQT07CQBTGv0JBhagk7HQzKxca2sJCE1hDt4QF+9JOS0nbaaYDCQfwCJ7Au3AHj+LO13FMmm6cl7785vven0kBjHCBhfpYuNa5Ph1c0e2Xu3jEvWG7UdPDLZ4N92nOm+EBXuAbHmIMSRMs+4aUEd4Nd3CHD8NdvOLTsA2GL8M9PODbcL+hD7C1xoaHeLJSEao0FEW14ckxC+TU8TxvsY6X0eLPmRhry2WVioLpkrbp84LLQPGI7c6sOiUzpWIWS5GzlSgUzzLBSikOPFTOXqly7rqx0Z1Q5BAIoZBSFihQYQOOBEdkCOgXTOHA07HAGjGWiIjaPZNW13/+lm6S9FT7rLHFJ6fQbkATOG1j2OFMucKJJsxIVfQORl+9Jyda6Sl1dUYhSCm1dyClfoeDve4qMYdLEbfqHf3O/AdDumsjAAB42mNgYoAAZQYjBmyAGYQZmdhL8zLdDEydARfoAqIAAAABAAMABwAKABMAB///AA8AAQAAAAAAAAAAAAAAAAABAAAAAA==) format('woff');
}
body {
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
color: #333;
font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 16px;
line-height: 1.6;
word-wrap: break-word;
}
a {
background-color: transparent;
}
a:active,
a:hover {
outline: 0;
}
strong {
font-weight: bold;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
img {
border: 0;
}
hr {
box-sizing: content-box;
height: 0;
}
pre {
overflow: auto;
}
code,
kbd,
pre {
font-family: monospace, monospace;
font-size: 1em;
}
input {
color: inherit;
font: inherit;
margin: 0;
}
html input[disabled] {
cursor: default;
}
input {
line-height: normal;
}
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
td,
th {
padding: 0;
}
* {
box-sizing: border-box;
}
input {
font: 13px / 1.4 Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
a {
color: #4078c0;
text-decoration: none;
}
a:hover,
a:active {
text-decoration: underline;
}
hr {
height: 0;
margin: 15px 0;
overflow: hidden;
background: transparent;
border: 0;
border-bottom: 1px solid #ddd;
}
hr:before {
display: table;
content: "";
}
hr:after {
display: table;
clear: both;
content: "";
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-top: 15px;
margin-bottom: 15px;
line-height: 1.1;
}
h1 {
font-size: 30px;
}
h2 {
font-size: 21px;
}
h3 {
font-size: 16px;
}
h4 {
font-size: 14px;
}
h5 {
font-size: 12px;
}
h6 {
font-size: 11px;
}
blockquote {
margin: 0;
}
ul,
ol {
padding: 0;
margin-top: 0;
margin-bottom: 0;
}
ol ol,
ul ol {
list-style-type: lower-roman;
}
ul ul ol,
ul ol ol,
ol ul ol,
ol ol ol {
list-style-type: lower-alpha;
}
dd {
margin-left: 0;
}
code {
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 12px;
}
pre {
margin-top: 0;
margin-bottom: 0;
font: 12px Consolas, "Liberation Mono", Menlo, Courier, monospace;
}
.select::-ms-expand {
opacity: 0;
}
.octicon {
font: normal normal normal 16px/1 octicons-link;
display: inline-block;
text-decoration: none;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.octicon-link:before {
content: '\f05c';
}
.markdown-body:before {
display: table;
content: "";
}
.markdown-body:after {
display: table;
clear: both;
content: "";
}
.markdown-body>*:first-child {
margin-top: 0 !important;
}
.markdown-body>*:last-child {
margin-bottom: 0 !important;
}
a:not([href]) {
color: inherit;
text-decoration: none;
}
.anchor {
display: inline-block;
padding-right: 2px;
margin-left: -18px;
}
.anchor:focus {
outline: none;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-top: 1em;
margin-bottom: 16px;
font-weight: bold;
line-height: 1.4;
}
h1 .octicon-link,
h2 .octicon-link,
h3 .octicon-link,
h4 .octicon-link,
h5 .octicon-link,
h6 .octicon-link {
color: #000;
vertical-align: middle;
visibility: hidden;
}
h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
h5:hover .anchor,
h6:hover .anchor {
text-decoration: none;
}
h1:hover .anchor .octicon-link,
h2:hover .anchor .octicon-link,
h3:hover .anchor .octicon-link,
h4:hover .anchor .octicon-link,
h5:hover .anchor .octicon-link,
h6:hover .anchor .octicon-link {
visibility: visible;
}
h1 {
padding-bottom: 0.3em;
font-size: 2.25em;
line-height: 1.2;
border-bottom: 1px solid #eee;
}
h1 .anchor {
line-height: 1;
}
h2 {
padding-bottom: 0.3em;
font-size: 1.75em;
line-height: 1.225;
border-bottom: 1px solid #eee;
}
h2 .anchor {
line-height: 1;
}
h3 {
font-size: 1.5em;
line-height: 1.43;
}
h3 .anchor {
line-height: 1.2;
}
h4 {
font-size: 1.25em;
}
h4 .anchor {
line-height: 1.2;
}
h5 {
font-size: 1em;
}
h5 .anchor {
line-height: 1.1;
}
h6 {
font-size: 1em;
color: #777;
}
h6 .anchor {
line-height: 1.1;
}
p,
blockquote,
ul,
ol,
dl,
table,
pre {
margin-top: 0;
margin-bottom: 16px;
}
hr {
height: 4px;
padding: 0;
margin: 16px 0;
background-color: #e7e7e7;
border: 0 none;
}
ul,
ol {
padding-left: 2em;
}
ul ul,
ul ol,
ol ol,
ol ul {
margin-top: 0;
margin-bottom: 0;
}
li>p {
margin-top: 16px;
}
dl {
padding: 0;
}
dl dt {
padding: 0;
margin-top: 16px;
font-size: 1em;
font-style: italic;
font-weight: bold;
}
dl dd {
padding: 0 16px;
margin-bottom: 16px;
}
blockquote {
padding: 0 15px;
color: #777;
border-left: 4px solid #ddd;
}
blockquote>:first-child {
margin-top: 0;
}
blockquote>:last-child {
margin-bottom: 0;
}
table {
display: block;
width: 100%;
overflow: auto;
word-break: normal;
word-break: keep-all;
}
table th {
font-weight: bold;
}
table th,
table td {
padding: 6px 13px;
border: 1px solid #ddd;
}
table tr {
background-color: #fff;
border-top: 1px solid #ccc;
}
table tr:nth-child(2n) {
background-color: #f8f8f8;
}
img {
max-width: 100%;
box-sizing: content-box;
background-color: #fff;
}
code {
padding: 0;
padding-top: 0.2em;
padding-bottom: 0.2em;
margin: 0;
font-size: 85%;
background-color: rgba(0,0,0,0.04);
border-radius: 3px;
}
code:before,
code:after {
letter-spacing: -0.2em;
content: "\00a0";
}
pre>code {
padding: 0;
margin: 0;
font-size: 100%;
word-break: normal;
white-space: pre;
background: transparent;
border: 0;
}
.highlight {
margin-bottom: 16px;
}
.highlight pre,
pre {
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: #f7f7f7;
border-radius: 3px;
}
.highlight pre {
margin-bottom: 0;
word-break: normal;
}
pre {
word-wrap: normal;
}
pre code {
display: inline;
max-width: initial;
padding: 0;
margin: 0;
overflow: initial;
line-height: inherit;
word-wrap: normal;
background-color: transparent;
border: 0;
}
pre code:before,
pre code:after {
content: normal;
}
kbd {
display: inline-block;
padding: 3px 5px;
font-size: 11px;
line-height: 10px;
color: #555;
vertical-align: middle;
background-color: #fcfcfc;
border: solid 1px #ccc;
border-bottom-color: #bbb;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #bbb;
}
.pl-c {
color: #969896;
}
.pl-c1,
.pl-s .pl-v {
color: #0086b3;
}
.pl-e,
.pl-en {
color: #795da3;
}
.pl-s .pl-s1,
.pl-smi {
color: #333;
}
.pl-ent {
color: #63a35c;
}
.pl-k {
color: #a71d5d;
}
.pl-pds,
.pl-s,
.pl-s .pl-pse .pl-s1,
.pl-sr,
.pl-sr .pl-cce,
.pl-sr .pl-sra,
.pl-sr .pl-sre {
color: #183691;
}
.pl-v {
color: #ed6a43;
}
.pl-id {
color: #b52a1d;
}
.pl-ii {
background-color: #b52a1d;
color: #f8f8f8;
}
.pl-sr .pl-cce {
color: #63a35c;
font-weight: bold;
}
.pl-ml {
color: #693a17;
}
.pl-mh,
.pl-mh .pl-en,
.pl-ms {
color: #1d3e81;
font-weight: bold;
}
.pl-mq {
color: #008080;
}
.pl-mi {
color: #333;
font-style: italic;
}
.pl-mb {
color: #333;
font-weight: bold;
}
.pl-md {
background-color: #ffecec;
color: #bd2c00;
}
.pl-mi1 {
background-color: #eaffea;
color: #55a532;
}
.pl-mdr {
color: #795da3;
font-weight: bold;
}
.pl-mo {
color: #1d3e81;
}
kbd {
display: inline-block;
padding: 3px 5px;
font: 11px Consolas, "Liberation Mono", Menlo, Courier, monospace;
line-height: 10px;
color: #555;
vertical-align: middle;
background-color: #fcfcfc;
border: solid 1px #ccc;
border-bottom-color: #bbb;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #bbb;
}
.task-list-item {
list-style-type: none;
}
.task-list-item+.task-list-item {
margin-top: 3px;
}
.task-list-item input {
margin: 0 0.35em 0.25em -1.6em;
vertical-align: middle;
}
:checked+.radio-label {
z-index: 1;
position: relative;
border-color: #4078c0;
}
.sourceLine {
display: inline-block;
}
code .kw { color: #000000; }
code .dt { color: #ed6a43; }
code .dv { color: #009999; }
code .bn { color: #009999; }
code .fl { color: #009999; }
code .ch { color: #009999; }
code .st { color: #183691; }
code .co { color: #969896; }
code .ot { color: #0086b3; }
code .al { color: #a61717; }
code .fu { color: #63a35c; }
code .er { color: #a61717; background-color: #e3d2d2; }
code .wa { color: #000000; }
code .cn { color: #008080; }
code .sc { color: #008080; }
code .vs { color: #183691; }
code .ss { color: #183691; }
code .im { color: #000000; }
code .va {color: #008080; }
code .cf { color: #000000; }
code .op { color: #000000; }
code .bu { color: #000000; }
code .ex { color: #000000; }
code .pp { color: #999999; }
code .at { color: #008080; }
code .do { color: #969896; }
code .an { color: #008080; }
code .cv { color: #008080; }
code .in { color: #008080; }
</style>
<style>
body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
padding-top: 0px;
}
</style>
</head>
<body>
<h1 id="civilytics">civilytics</h1>
<p>Brand themes, color palettes, and utility functions for <a href="https://www.civilytics.com">Civilytics Consulting</a>. The package
provides a complete ggplot2 theme system drawn from the Civilytics
design system — warm paper backgrounds, civic-navy ink, and editorial
typography — along with 10 curated color palettes, logo composition
helpers, and data-wrangling utilities for public-sector analysis.</p>
<h2 id="installation">Installation</h2>
<p>Install from the Civilytics Gitea server:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="co"># install.packages(&quot;remotes&quot;)</span></span>
<span id="cb1-2"><a href="#cb1-2" tabindex="-1"></a>remotes<span class="sc">::</span><span class="fu">install_git</span>(<span class="st">&quot;https://gitea.civilytics.org/Civilytics/civilyticsR.git&quot;</span>)</span></code></pre></div>
<h2 id="quick-start">Quick start</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" tabindex="-1"></a><span class="fu">library</span>(civilytics)</span>
<span id="cb2-2"><a href="#cb2-2" tabindex="-1"></a><span class="fu">library</span>(ggplot2)</span>
<span id="cb2-3"><a href="#cb2-3" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" tabindex="-1"></a><span class="fu">ggplot</span>(mpg, <span class="fu">aes</span>(displ, hwy, <span class="at">colour =</span> class)) <span class="sc">+</span></span>
<span id="cb2-5"><a href="#cb2-5" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">size =</span> <span class="fl">2.5</span>) <span class="sc">+</span></span>
<span id="cb2-6"><a href="#cb2-6" tabindex="-1"></a> <span class="fu">scale_color_civilytics</span>() <span class="sc">+</span></span>
<span id="cb2-7"><a href="#cb2-7" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb2-8"><a href="#cb2-8" tabindex="-1"></a> <span class="at">title =</span> <span class="st">&quot;Fuel economy by engine displacement&quot;</span>,</span>
<span id="cb2-9"><a href="#cb2-9" tabindex="-1"></a> <span class="at">subtitle =</span> <span class="st">&quot;Highway MPG vs. engine size for 234 vehicles&quot;</span>,</span>
<span id="cb2-10"><a href="#cb2-10" tabindex="-1"></a> <span class="at">caption =</span> <span class="st">&quot;Source: EPA fuel economy data (ggplot2::mpg)&quot;</span>,</span>
<span id="cb2-11"><a href="#cb2-11" tabindex="-1"></a> <span class="at">x =</span> <span class="st">&quot;Engine displacement (litres)&quot;</span>,</span>
<span id="cb2-12"><a href="#cb2-12" tabindex="-1"></a> <span class="at">y =</span> <span class="st">&quot;Highway MPG&quot;</span></span>
<span id="cb2-13"><a href="#cb2-13" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb2-14"><a href="#cb2-14" tabindex="-1"></a> <span class="fu">theme_civilytics</span>()</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAIAAAD9Gkc5AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdZVwUWxsA8LPA0g3SHSKgIBKSIhImqNit2K332nXt1tfu7gIVCwkFBQVROqW7u1nYfT8MDiMsy8JSrs//tx9mz8ycc2bmzD47M2dmSPU15QgAAAAA7IWjtysAAAAAgK4HAR4AAABgQxDgAQAAADYEAR4AAABgQxDgAQAAADYEAR4AAABgQxDgAQAAADYEAR4AAABgQxDgAQAAADYEAR4AAABgQxDgAQAAADYEAR4AAABgQxDgAQAAADYEAR4AAABgQxDgAQAAADY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oIr6/hBhvWCmu+xoPTklB9uOrO9MWrMdriCGTuQYP0p7k6DBnmhMPT9f/8WV90bi5yXW/+sd0+l1Q3NzkM4e3L5k75fHzd1+CQqPjk1o8OyUkPOafbUduXzzUVg6YiqrmfxvEv3p0xcQlTpy1En/3zKwpjgvnTNIdoEGlUmUHDGs9fYf23B5oM32qXMDe+nqA11RTjvjVcfTk/s1WZka9lbOGmnJIeAw2HPczeYTVUOLYoLine truncated
<h2 id="color-palettes">Color palettes</h2>
<p>The package ships 53 named brand colors in
<code>civilytics_colors</code> and 10 curated palettes in
<code>civilytics_palettes</code>. Use <code>civilytics_palette()</code>
to retrieve colors by name, or pass palettes directly to the ggplot2
scales.</p>
<h3 id="palette-gallery">Palette gallery</h3>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAANgCAMAAADEfSr3AAAC9FBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4OGisPDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZEC4aGhoaLkobGxscHBwdHR0fHx8fb3AgICAhISEiIiIiQGojIyMkJCQlJSUmJiYoKCgpKSkqG00qKiorKyssLCwtLS0uLi4uVZAvLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9Kms9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFGgBFRUVGRkZHR0dISEhJSUlKSkpKdLBLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhaWlpaaoJbW1tcOopcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZGRlZWVmZmZnZ2doaGhpaWlqamprKwBrOl5ra2tubm5vb29wcHBxcXFycnJzc3N0dHR1Vqh1dXV2dnZ3d3d4eHh6enp6m8p7e3t8fHx9fX1+fn5/f3+AgICBgYGCgoKDg4OFhYWGhoaHh4eJiYmNjY2Ojo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pGB1AyOoCS0QGUjA6gZHQAJaMDKBldWoDOLtudjmWI+pUWoCLhdCxD1C+AktG5QF+reY/v/PtOWFsHqoqC5Xvs5zZPzpm4/na/d3TfQZ9sqx1XvPboivHFa2ygTTfmTWjqTRwRWZCf2WuhUZgLtEJuWHONNFjAikL1DYW5FrGwyOKGwhzvS2z8oEhw8U0iMxbNF9lv7RV9ZVmubEgcMTbgH/BPEg0/119Advb0Pn1MtUoaDh1qlHLVy6RatUW8QOMHRVr0hEiz/fCotfeQ6t1ySeKIm9/pycol0WjK9VclUlix3gJaJNGCqnmyJfoy6hkcPxi96+x7iG60S17iiEeyckE0unL9HW9dMFHkDtWg1EesdtlA25OBxg8OCDS/3wiiFHP8nXq4Q/UpCaheK7WqxzYeVp0hNarbE4DGDyYDbVGtlcv7jSBKMcffK/n5dzVdLXNV9+bJwtXTpVW1TaSmsSQBaPxgElBf4T1Lc+y9pBFEKeb62181zlda94a11TEvPzBzm7XR21wamLM8AWj8YK7s8DzkVmydlDO5tf8IohQb4ov66D1od5ddd2ZOiMjbEEAj4rPfraNl5oSIvMGOjA6gZHQAJaMDKBkdQMnoAEpGB1AyuuEC/b8Ucpf43xRyVvhdCrkn8d8p5C7x2xRyl/hVCrlL/CSFnBW+nULuSfxZCgEUoAAFKEABClCAAhSgAAUoQAEKUIACFKAABShAAQpQgAIUoAAFKEABClCAAhSgAAUoQAEKUIACFKAABShAAQpQgAIUoAAFKEABClCAAhSgAAUoQAEKUIACFKAABShAAQpQgAIUoAAFKEABClCAAhSgAAUoQAEKUIACFKAABShAAQpQgAIUoAAFKEABClCAAhSgAAUoQAEKUIACFKAABShAAQpQgAIUoAAFKEABClCAAhSgAAUoQAEKUIACFKAABShAAQpQgAIUoAAFKEABClCAAhSgAAUoQAEKUIACFKBE2Q2gZHQAJaMDKBkdQMnoAEpGBLine truncated
<h3 id="using-palettes">Using palettes</h3>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a><span class="co"># Discrete fill with the qualitative palette</span></span>
<span id="cb3-2"><a href="#cb3-2" tabindex="-1"></a><span class="fu">ggplot</span>(mpg, <span class="fu">aes</span>(class, <span class="at">fill =</span> class)) <span class="sc">+</span></span>
<span id="cb3-3"><a href="#cb3-3" tabindex="-1"></a> <span class="fu">geom_bar</span>(<span class="at">show.legend =</span> <span class="cn">FALSE</span>) <span class="sc">+</span></span>
<span id="cb3-4"><a href="#cb3-4" tabindex="-1"></a> <span class="fu">scale_fill_civilytics</span>() <span class="sc">+</span></span>
<span id="cb3-5"><a href="#cb3-5" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">title =</span> <span class="st">&quot;Vehicle counts by class&quot;</span>, <span class="at">x =</span> <span class="cn">NULL</span>, <span class="at">y =</span> <span class="cn">NULL</span>) <span class="sc">+</span></span>
<span id="cb3-6"><a href="#cb3-6" tabindex="-1"></a> <span class="fu">theme_civilytics</span>(<span class="at">grid =</span> <span class="st">&quot;y&quot;</span>)</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAFQCAIAAADvJFsWAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nO3dZ1wURwPH8Tna0UHEXkBQEY0VS+y9t6hoYixRNJrYYhKjxpJEozHWGKPG3jXG+gixd2PvNfbesIGgdOSeF2vWk3KCLFwcft8PL/Zm93Zmh+H+bD1dbFS4AAAAcrEwdwMAAID2CHgAACREwAMAICECHgAACRHwAABIiIAHAEBCBDwAABIi4AEAkBABDwCAhAh4AAAkRMADACAhAh4AAAkR8AAASIiABwBAQgQ8AAASIuABAJAQAQ8AgIQIeAAAJETAAwAgIat0vj8qOrpYhSYJCQnKyzLvFQv6c0ayS165drN+q27x8fFCiIL58+7bvOztaixarlFUTLQyvXn1nOLFCpte3sevcWR0lDK9Zc1cXx/vTKgUmviPd/t/vHkAsrj0BrydrW0hj/xnz19WXh44eur6zTuFPPInXTJ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BnaOdeg7VtZ9ePW7s4vfyH4+TZC8NH/6rc1BcfHz9y7DQlPq2sLP1MPms2/Y1PUzMCOrZWL2LYvLine truncated
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a></span>
<span id="cb4-2"><a href="#cb4-2" tabindex="-1"></a><span class="co"># Continuous fill with a sequential palette</span></span>
<span id="cb4-3"><a href="#cb4-3" tabindex="-1"></a><span class="fu">ggplot</span>(faithfuld, <span class="fu">aes</span>(waiting, eruptions, <span class="at">fill =</span> density)) <span class="sc">+</span></span>
<span id="cb4-4"><a href="#cb4-4" tabindex="-1"></a> <span class="fu">geom_tile</span>() <span class="sc">+</span></span>
<span id="cb4-5"><a href="#cb4-5" tabindex="-1"></a> <span class="fu">scale_fill_civilytics</span>(<span class="st">&quot;seq_ember&quot;</span>, <span class="at">discrete =</span> <span class="cn">FALSE</span>) <span class="sc">+</span></span>
<span id="cb4-6"><a href="#cb4-6" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">title =</span> <span class="st">&quot;Old Faithful eruption density&quot;</span>) <span class="sc">+</span></span>
<span id="cb4-7"><a href="#cb4-7" tabindex="-1"></a> <span class="fu">theme_civilytics</span>(<span class="at">grid =</span> <span class="st">&quot;none&quot;</span>)</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAFQCAIAAADvJFsWAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOydd3gU1dfHz/b0hBASSkJCQu+CFAEpgkgRpItiAUFExIb+FBUUe8PyolhAkaYCUqQLiBRBEJQOgQQICQkJENLL1pn3j8VlSc4ms5ndbLL5fh4ent2zd+69OzPZM997zz1XYSzOIwAAAAB4F0pPdwAAAAAArgcOHgAAAPBC4OABAAAALwQOHgAAAPBC4OABAAAALwQOHgAAAPBC4OABAAAALwQOHgAAAPBC4OABAAAALwQOHgAAAPBC4OABAAAALwQO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21VoFBPpKLGrQqEIDPCvxH4REeXbDQ75+ujKKCmFAH9fm8ctceOVeBvozwSTVgBnb3V3XwutVjP3g9cmPzJ6xdotf/195NTZ8yWebg8fOz391Q8Xf13OcpJyiY2J7Nyh7cHDN2bfl6/eItCNya+xwwfKHyQAAJB8B18i4mb7rv1j7CJorOzYdctCKfvAKJZ6EXUuptyQ0UnJqS7PMsvyziff2Lz7s088PLine truncated
<h2 id="themes">Themes</h2>
<p>Three theme variants cover the most common output contexts. All share
the same typographic structure and accept <code>grid</code> and
<code>paper_bg</code> parameters.</p>
<h3 id="editorial-default">Editorial (default)</h3>
<p>The default theme uses a warm paper background with horizontal
gridlines — an editorial, Pew-style layout.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a>base_plot <span class="ot">&lt;-</span> <span class="fu">ggplot</span>(mpg, <span class="fu">aes</span>(displ, hwy)) <span class="sc">+</span></span>
<span id="cb5-2"><a href="#cb5-2" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="fu">aes</span>(<span class="at">colour =</span> <span class="fu">factor</span>(cyl)), <span class="at">size =</span> <span class="dv">2</span>) <span class="sc">+</span></span>
<span id="cb5-3"><a href="#cb5-3" tabindex="-1"></a> <span class="fu">scale_color_civilytics</span>() <span class="sc">+</span></span>
<span id="cb5-4"><a href="#cb5-4" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb5-5"><a href="#cb5-5" tabindex="-1"></a> <span class="at">title =</span> <span class="st">&quot;Engine size vs. highway fuel economy&quot;</span>,</span>
<span id="cb5-6"><a href="#cb5-6" tabindex="-1"></a> <span class="at">subtitle =</span> <span class="st">&quot;Colored by number of cylinders&quot;</span>,</span>
<span id="cb5-7"><a href="#cb5-7" tabindex="-1"></a> <span class="at">caption =</span> <span class="st">&quot;Source: ggplot2::mpg&quot;</span>,</span>
<span id="cb5-8"><a href="#cb5-8" tabindex="-1"></a> <span class="at">colour =</span> <span class="st">&quot;Cylinders&quot;</span>,</span>
<span id="cb5-9"><a href="#cb5-9" tabindex="-1"></a> <span class="at">x =</span> <span class="st">&quot;Displacement (L)&quot;</span>, <span class="at">y =</span> <span class="st">&quot;Highway MPG&quot;</span></span>
<span id="cb5-10"><a href="#cb5-10" tabindex="-1"></a> )</span>
<span id="cb5-11"><a href="#cb5-11" tabindex="-1"></a></span>
<span id="cb5-12"><a href="#cb5-12" tabindex="-1"></a>base_plot <span class="sc">+</span> <span class="fu">theme_civilytics</span>()</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAIAAAD9Gkc5AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdZ1wTSRsA8Akp9F6l96ogKqCggh27Yq9n711PfS136ul5euqpp56994IKVhQBpSmKgNJ7770F0t4Pi2tIQhJIAInP/+eH3cnO7GRZ8+zOzswSGuurEAAAAAAki1RnVwAAAAAA4gcBHgAAAJBAEOABAAAACQQBHgAAAJBAEOABAAAACQQBHgAAAJBAEOABAAAACQQBHgAAAJBAEOABAAAACQQBHgAAAJBAEOABAAAACQQBHgAAAJBAEOABAAAACQQBHgAAAJBAEOABAAAACQQBHgAAAJBAEOABAAAACQQBHgAAAJBAEOABAAAACUQSMf/spZuDgj8Is+XWDUtWLpwp4u6EZ9V7ZB21Hlv2875gY2XWYbtus65YZ7Gz7OVZ30DFll8+OG9rbc5/e/EetNbuveui0+knzt+46/0iJ6+AxWIhhBTl5eM+PO2Yvf88xxmATiRqgK+urq2nNgizZW1NnYj7apXSiorvu66r78hdt1lXrLPYlVVW4st19VSB24v3oLV2713Xzj+Pn7tyjz1FyP/IYvHzHGcAOpGoAR4A0OVUVddevO6Nr8rISNtamsrIyHRilQAAYtdxAV5FWanD9oUQUlSQq66pQwiRSCTVjt11m3XFOnc6OGhtkJqRxWAw8NWb5w4NdO3TifUBALQHcQb4+1eOefR3FmOBokiP9u/sKrRaV6xzp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/fRmIJw5x78e+jUtve3zZzz+YvV2OHXsntWUbdi9Zu/PanccpqZksFsvYUG/6pFFkMln4OiOEXgeG/XvuOr66fvkv7EMTRa8wmUyeOtETX7336CXWvPwu7FNhUQlCSEZG2mvc8Hb6dhzYHz2oqTTrr9dS/TFiOWeE2buVhYmJsT62XFdPDf3wGSH05m04au5lQAhCqKik9POXeISQmooyfs0hJyvj7ua0ee2iU4d+o1DIePmcHd0ZTY8k3Fx6Gejp4On3v7XB4q2vnkMGqKkqow4k+lknrpKfv3qLJ04aO5x9++mTRuXGBUUGeT+7dwbr3fbi9fd+qZ5DB7Bv7Dm4P74cFPyBRuPsBCPMr4co5ZuzPUORa14+ezdSWRlp7v3+gGcI6CztHuBlZKUFb8SXoX43517f/zOv3LQnNj6ZRqMlp2as/d+fePoQ974cT6ZF9yUuGV/2mrOa/dGDQffvt27lldUFhcU8S5gxeTS+TKU2eD95vX7bX32HT7fqM3L+ym0+z9+w32gKVFBYvPJbL3eEkFOvHlvWLRJvhVHzVvri0rLXAWEIodvfbuXHjPDA47p4v50YdeQ5M3oYWyt9QChC6HVgGEJITlYGf0CbmpaVlp6NHUmE0Iih/bE7SxyNRnv09PWyDbv6Dptu1GOQprmrXV/ejagEAmHGpO+H/fHT1w0NjVRqg8/zpvkAZk0dJ+I3ai2xnHViKTkhKQ1PtDA35l94YvL33iGmxgbsHxkbfV9taGjkuCgUUnuX35If8AwBnUWcveh9bp0SpT2Wj9P/7PKaszojKxchFPU1wX0M5+gOW2tz9mer4lJeWSV4I4QQQsWl5TxDxbYNS8sqKm/ee8KRXlZR6fsiwPdFQC8H21sXDnPccfLEYDCWrPsd78asoqR47tgfeKu4uCqMELIwM3buZLine truncated
<h3 id="grid-options">Grid options</h3>
<p>The <code>grid</code> parameter controls which major gridlines are
drawn.</p>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAJwCAIAAADZYES9AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElE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w7VcOh9vuW1vb9vx9xtLcpC4tR55K+Fw2jiBLb1RUWuHsYLV68QxhiWlH3nNFcTlcgky/irqGxvmrf9TUUP9q+Sd62lovYxI27zjQ1MSYMi60w23g8vB4XEcXKeByecs2/FJdU7dw9ngLqlFKZt7xc3cKi8t3bFna0Qb0eJB3yLtA78x77+rgc4vKw18mEAj4DZ9PcXWwRAiVlFf/8Oe5xLT8FzHJgwM9paxHQ52MELkzW9oCj8eT/s0IE5vDOX715dlbUcXltSYGOpPC+i6bNVRDvcM/QlRsYlxC+rplMzdu/1uGZnDpTUXX/qyMuMqqLacYW1KHzzMbuaBDyS+vqHGwtRgYIPsqJiw66+Hpe68fRNdX1elTDQaMHxQ6bSiR1IEgHD51k0gknti7VUNDDSEUOqgvj88/eel+hwL/7k3Wkf0PMlKKCES8T1+7patH2zqaSvnajJz89Kz8w79v9vN2RQgNHthHW0tjz99ntqyeq6mpJn0bejzIO+S9l+e9d3XwSWl5CLine truncated
<h3 id="dark">Dark</h3>
<p>Dark navy background with light text, suitable for presentations or
dashboards on dark surfaces.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" tabindex="-1"></a>base_plot <span class="sc">+</span> <span class="fu">theme_civilytics_dark</span>()</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAIAAAD9Gkc5AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdd5gkVbkw8PecU1VdHacnh53ZyAYWWHYBQZCMgaCCiAiYvYqIckW96mdEUTBeAwoKKNcACAIGJEhccs67sCzLwsbJuWOFc873R83W9ExXh+nuSb3v7+Hh6amuPnW6urbeOpm0rTkZEEIIIVRd6GxnACGEEEKVhwEeIYQQqkIY4BFCCKEqhAEeIYQQqkIY4BFCCKEqhAEeIYQQqkIY4BFCCKEqhAEeIYQQqkIY4BFCCKEqhAEeIYQQqkIY4BFCCKEqhAE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Pbwypi9YrF7uu/XvHtXLtFa8LNjbWeR7/5tgc+85H3Oq91n3bqu97m1JINDseeePblf9/7+F3rnxJuN5tCmhqi/3vR+e6/5Gdf3PyLq26qbIYB4MZb7z93T6misb7muLetu/fhZ884Zawof8f9T7pd6yv77SpoJq+Zux942j0Jx7/toLine truncated
<h3 id="slide">Slide</h3>
<p>Transparent background and larger base font (18 pt), sized for
Reveal.js slides or PowerPoint exports.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" tabindex="-1"></a>base_plot <span class="sc">+</span> <span class="fu">theme_civilytics_slide</span>()</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAIAAAD9Gkc5AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdZ1zTWhsA8KdA2XtvBFFAQBRREPfGjeBeuPde14t63de9t173xL1RcaCCiCBbZe+99yzt+yG+MbQFWmgB8fn/+EBOTpKT5LRPk5xzQmOxWIAQQgih1kWkuQuAEEIIIcHDAI8QQgi1QhjgEUIIoVYIAzxCCCHUCmGARwghhFohDPAIIYRQK4QBHiGEEGqFMMAjhBBCrRAGeIQQQqgVwgCPEEIItUIY4BFCCKFWCAM8Qggh1AphgEcIIYRaIQzwCCGEUCuEAR4hhBBqhTDAI4QQQq0QBniEEEKoFcIAjxBCCLVCGOARQgihVggDPEIIIdQKYYBHCCGEWiEM8AghhFArhAEeIYQQaoUwwCOEEEKtEAZ4hBBCqBXCAI8QQgi1QhjgEUIIoVYIAzxCCCHUCmGARwghhFohDPAIIYRQK4QBHiGEEGqFxIS9gXlL15eWlfG1iIS4xPmTe4VUngaYv+zvktJScnLTX8tN2hk1Y3kErtXvoFCx1fANa5eamRjzvrhQD34jy/aHKCgofPjsVVDI9+ycPBaLSSTKy8udPLijeQvGdvo2rltm2r5tM5YH/XZoLBZLqBtQ0LFowFIFKWECL0mDse2C26XjDo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y9DIzwJfH8zGbKuiotKqe40Py7K1m6nfY3sPn6bO3b7naG0Lbty+n7pRLx8/Jb2O1Axf/INq20G+vj8Fu2llfau7D5+Tc5+4v2bLoKTX8dqtB3Vk+PjpCzlXGBW1YVrQLfqi4uL6MwHs2LRmweyp1F9DI4cNomZgaxSWk5tHnZQQF2dboaSEBHUyITGFl2I0vmzPX7379iOSnJw/a7JNZ0tq5jb6ussWzCAnCwqL3O4/rWPrCUmp1Em2NkrSUlKnj/x79dyhsC+v169aqCAvx8secfIPCHHdUuP+Xv/e9utXLSInBb5fADBr2njqZHJq+hvPXz+QX7x+T17ItmtrSDZSa5oDwmaOy8Sr5w5paqgRk7Iy0vNqtnfjsdEiCKHq8lU2GWnpwQN6Uee+eP2e+IfBYLx9X+PSCgCqqhgeb38OGvPq7UcG4+fFk+PIX5dcOtqa8d+8P72+f3jPZpfJzpdOH1BVUaauZMxIB+ok0ciLNGRgb7YGU1dvPSD/zy8ofPLiDfG/pKTE1Ilj2Pe/yQnjsyCMbT14+pJ6Z15VRXn31vXU77FVS+Z0MG2nqCDf3tioh50N0aiTc0FtLY1//lpG3WgPO5upNe9XHT19qbZd4Ov7U7Cb3rl5rfPooeTkwL492TJsWLuEeuONMwP1TmfLqai/QSt6Nm0N9dlSJCXYv/hq5jegPtSZuXDN0b1b2hkbAgCLxfrk+3XHvmPU/A24M9+wsj2k3P8EAEZ1NecTprSMLOrkqzcf6mgOJi8vm5dXQE4OHDnZefTQnvbd7Lp2Jpp4iIqKjqr5geFXdk7utHkrye9uANDW0jh3fDe1AYvA9wsARg0bpKKsRA14l2/cG9S/F/k/mT7HZQL5BdEEB4TToH492drJU1vY8kXgVZffso0ePvjRMw9y0t3D85/1ywHgs18g9TY76dmLN06jHIh/qCuh5hERETE3a29u1Line truncated
<h3 id="facets">Facets</h3>
<p>Facet strips use the <code>paper_2</code> tint, with the title
font.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" tabindex="-1"></a><span class="fu">ggplot</span>(mpg, <span class="fu">aes</span>(displ, hwy)) <span class="sc">+</span></span>
<span id="cb8-2"><a href="#cb8-2" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">colour =</span> civilytics_colors[<span class="st">&quot;navy_600&quot;</span>], <span class="at">size =</span> <span class="fl">1.5</span>) <span class="sc">+</span></span>
<span id="cb8-3"><a href="#cb8-3" tabindex="-1"></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span>class, <span class="at">ncol =</span> <span class="dv">4</span>) <span class="sc">+</span></span>
<span id="cb8-4"><a href="#cb8-4" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb8-5"><a href="#cb8-5" tabindex="-1"></a> <span class="at">title =</span> <span class="st">&quot;Highway MPG by vehicle class&quot;</span>,</span>
<span id="cb8-6"><a href="#cb8-6" tabindex="-1"></a> <span class="at">x =</span> <span class="st">&quot;Displacement (L)&quot;</span>, <span class="at">y =</span> <span class="st">&quot;Highway MPG&quot;</span></span>
<span id="cb8-7"><a href="#cb8-7" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb8-8"><a href="#cb8-8" tabindex="-1"></a> <span class="fu">theme_civilytics</span>(<span class="at">grid =</span> <span class="st">&quot;y&quot;</span>)</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAHgCAIAAAD17khjAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdZ1gTWRcA4Jseeu8gSBURFBuCoqiABRv23ntfP1exrr3s6q666tp7711RREXACgqoCAoiRXqHkJ7vx+AwJJRAgglw3ocfM3faYSaTk5m59w6JW1aEAAAAANC0kBUdAAAAAADkDxI8AAAA0ARBggcAAACaIEjwAAAAQBMECR4AAABogiDBAwAAAE0QJHgAAACgCYIEDwAAADRBkOABAACAJggSPAAAANAEQYIHAAAAmiBI8AAAAEATBAkeAAAAaIIgwQMAAABNECR4AAAAoAmCBA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Qj5ACOnr6WLXypjC4mJDRvlTAAZNnh8kU5OKg5uemYMNyL4Dx48ciCf47Ny8oCcv+vp4Xvh5KT+gjxdenTDmU8WPlaETFlS3wvzC4ozMbNk/irjP8Yn4sJ2tVf1WInvwcgkDI/0JMma4H34+stmca3eCrt0JQgjpamt17dLef4C3n28P/Oyr08wANFvy/F6m02hVFNKrKKzBgX/WDZ2wICk5DSH0/sPnHgPEmzy1bmVLfB5fb/19uuPfEUEhL5bkT37/4TNCyNvLo2ULs90HTLine truncated
<h2 id="logo-utilities">Logo utilities</h2>
<p>Add the Civilytics logo to any ggplot using the pipe-friendly
<code>civilytics_logo()</code> or the lower-level
<code>add_logo()</code> / <code>make_logo_grob()</code>. The logo is
automatically right-aligned below the plot area. Wrap the ggplot chain
in parentheses before piping — R’s <code>|&gt;</code> binds tighter than
<code>+</code>.</p>
<h3 id="wordmark-on-a-light-plot">Wordmark on a light plot</h3>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" tabindex="-1"></a>p <span class="ot">&lt;-</span> <span class="fu">ggplot</span>(mpg, <span class="fu">aes</span>(displ, hwy, <span class="at">colour =</span> class)) <span class="sc">+</span></span>
<span id="cb9-2"><a href="#cb9-2" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">size =</span> <span class="dv">2</span>) <span class="sc">+</span></span>
<span id="cb9-3"><a href="#cb9-3" tabindex="-1"></a> <span class="fu">scale_color_civilytics</span>() <span class="sc">+</span></span>
<span id="cb9-4"><a href="#cb9-4" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb9-5"><a href="#cb9-5" tabindex="-1"></a> <span class="at">title =</span> <span class="st">&quot;Fuel economy by engine displacement&quot;</span>,</span>
<span id="cb9-6"><a href="#cb9-6" tabindex="-1"></a> <span class="at">caption =</span> <span class="st">&quot;Source: EPA fuel economy data (ggplot2::mpg)&quot;</span>,</span>
<span id="cb9-7"><a href="#cb9-7" tabindex="-1"></a> <span class="at">x =</span> <span class="st">&quot;Displacement (L)&quot;</span>, <span class="at">y =</span> <span class="st">&quot;Highway MPG&quot;</span></span>
<span id="cb9-8"><a href="#cb9-8" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb9-9"><a href="#cb9-9" tabindex="-1"></a> <span class="fu">theme_civilytics</span>()</span>
<span id="cb9-10"><a href="#cb9-10" tabindex="-1"></a></span>
<span id="cb9-11"><a href="#cb9-11" tabindex="-1"></a>grid<span class="sc">::</span><span class="fu">grid.draw</span>(<span class="fu">civilytics_logo</span>(p))</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGwCAIAAAD5YECUAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdd1wT5xsA8PcuCwgBwt57I4iiooA4cODAvWrVWrfWOlutdWvVn611a617r9a6916ooICAIIrsJXtm5+73BxACBEwwBojP99PPp/Lmcvdc7r33uXvvvTtMwC1FAAAAAFAveHMHAAAAAADlgwQPAAAAqCFI8AAAAIAaggQPAAAAqCFI8AAAAIAaggQPAAAAqCFI8AAAAIAaojZ3AJ+DyLq0afbpFDFCCCHMoMe6LSM9WvUKgSqwZeVCctKuHz71T0SumO0UPP6bb7x0seYOSV7i9BNLfj+bUbmFKRYhP+34xoZS/WFzrxdUP6AmPl1tiby7vy44Fy9ubBrMqOf6P0e4q3wf4GQlPHsRJ0QIIYSbOxSTqg4AfCGwZeUgjj+wfPLWd0KEEAq98Sjf4P6yvlrNHZScSE5abOTThMpmBXf0riAQqk7wzb9eUP2AepAjJ/PyYsMjnwsbm4Ri5QzPwwNAtcRZGbmi6j+IkpyMUgJpqcFFN3VdL/BJJDf7XWQah0SYvr2nmxHl098AjYLdBoBWiurp396wag/GtNw6djFUj91ZXdcLfApZem3t7MFjZw0eO/e3RxzoN/l8ivaqUw2s7cy16+5vuImxtrIiAgDIBTcZtPqR44C7UVlCface3bws1eQ6sbquF/gEIv/R2Sc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0IR+RGPU1q9Ll6Sl0Kkf3seozk5JfiNG6RZM9ECFF1rP2HDu1rU/2trKfXaiameU5eMK8y3SKEcL3OsxZMl4woJCseXXlWILtXiuE7feEkt+qeRob12Gm9aoaDiQuy88TKXBymETDzx2HWlU0VpuU+clpXrZr9CtMNXvBDf/PKkxOM5TVqShe65FNxQWFB9abADXuM61m9dCR8ff1RanWYiXcexkuOQgy6ju6u4H6LGw6bO7GyXUYIY7oM+9+MtprVH5Jl0Y/jRMoNQBm1Ud6NKEoKf5wlOdmjuE9cOL9j9apq2YxaOXMA+/NPXuSuUcrbDUWJr0I/1qyX63e/LA2oGsSFaVqPWDajn56irTfGYutQq79Eltxf++s/T7Kqo6UwHQL69nWmN/jtWrUIMayCVs3qKKnoklokH7pdx061sjtCiG7n21ayqUhefl5x9dor1oZ8/iZQ0h6tyr0AfCEt5Q5Twdv4uJpeHlHM6U3zrkrt/2RFrOQQQvwxPVuM3JrSYdCEpQgS3sZLvkIx693HtZGTllrzp1r06GpTK0qqba+uFn/Gp1Ud5L9580Y0sHv9Ww6pDr271eoPodnZOVBQZlV7IRJWN0TKWRzFsbuf1Jk9pulgb0JBSVULoXv06qIj1TpoO9ob4ZLRbGJxzQ6KMXuOCjK/eq7yM8Gb+9fSx8y2xZE49dpNSQ8ebhYcHKitYMtOd/VrL/2r4xbd/Tw2RL6sDJEoSkoqI331MeUFoITaKPdGFCYnp0h+RIpFUA876U2EsTr0akc7f+/zBp40rUZ93m4oTE6tWS+qVZ8+TtL5ENPtENSOfvG+QuuFMTsHBrIe3qgcmUvy3l7cPPTaIY+gAd+PHTLcz+ITW7VeLTLq0smT8vxFnVokVyREacrrOw8jIhLS03OLyjkiESIRQsXJUmOGxaRk7ZvehjRtEyhpj1blXgC+EJUneBLJOLine truncated
<h3 id="compact-mark">Compact mark</h3>
<p>Use <code>type = &quot;mark&quot;</code> for the compact C-pulse icon instead
of the full wordmark.</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" tabindex="-1"></a>p2_logo <span class="ot">&lt;-</span> <span class="fu">ggplot</span>(mpg, <span class="fu">aes</span>(displ, hwy, <span class="at">colour =</span> <span class="fu">factor</span>(cyl))) <span class="sc">+</span></span>
<span id="cb10-2"><a href="#cb10-2" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">size =</span> <span class="dv">2</span>) <span class="sc">+</span></span>
<span id="cb10-3"><a href="#cb10-3" tabindex="-1"></a> <span class="fu">scale_color_civilytics</span>() <span class="sc">+</span></span>
<span id="cb10-4"><a href="#cb10-4" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb10-5"><a href="#cb10-5" tabindex="-1"></a> <span class="at">title =</span> <span class="st">&quot;Engine size vs. highway fuel economy&quot;</span>,</span>
<span id="cb10-6"><a href="#cb10-6" tabindex="-1"></a> <span class="at">colour =</span> <span class="st">&quot;Cylinders&quot;</span>,</span>
<span id="cb10-7"><a href="#cb10-7" tabindex="-1"></a> <span class="at">x =</span> <span class="st">&quot;Displacement (L)&quot;</span>, <span class="at">y =</span> <span class="st">&quot;Highway MPG&quot;</span></span>
<span id="cb10-8"><a href="#cb10-8" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb10-9"><a href="#cb10-9" tabindex="-1"></a> <span class="fu">theme_civilytics</span>()</span>
<span id="cb10-10"><a href="#cb10-10" tabindex="-1"></a></span>
<span id="cb10-11"><a href="#cb10-11" tabindex="-1"></a>grid<span class="sc">::</span><span class="fu">grid.draw</span>(<span class="fu">civilytics_logo</span>(p2_logo, <span class="at">type =</span> <span class="st">&quot;mark&quot;</span>))</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGwCAIAAAD5YECUAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdd3wT5RsA8Ocuq0n33rulk9JSyt5D9h6CgixFQRQUlR8yRBHciiJDAQWUDbL33pRSOunee+9m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GWqL9v5eOX3eXbXIS94ly3F4Y8nIupEUsuLcwtrNLE0JuVc3hozhvWDVR0FGNW8keI6zvlg63rjtoaobDJX/4EKYInuZTlg41qHuQIi0HjN9glVtNaog/EFKMzf5I/SNDZjyfEaX39r0+fH7OfJPZui6Dhw9utuLTEmgiu+tW30ysXaPz7Cd/OmPk2tj0lzwwHB67fVADiFf5NUrEfKOXirvxq0QeVYkLYbMHlTzrbbX+jaBHfTuJ+/61G5QQsf5rfdGWqnaoM3QXMNTNxiOX59BtUsAujrybrQEAEASe/8ZnwYA0qDnwAmDerABAKiykJBUKQCA6Mn9SHkfLWk/oG+3ekfmbOeg3vWyOwCwnfv0UIROC4sKy+RrSZoNmzvcUP6SJOLS3XR5w0+6fidWkR5MB70+VANDJV6MBpuxZpdC5T66FKXorLine truncated
<h3 id="multi-plot-layout-with-logo">Multi-plot layout with logo</h3>
<p>Use <code>add_logo_ga()</code> to attach a single logo below a row of
plots.</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" tabindex="-1"></a>p1 <span class="ot">&lt;-</span> <span class="fu">ggplot</span>(mpg, <span class="fu">aes</span>(class, <span class="at">fill =</span> class)) <span class="sc">+</span></span>
<span id="cb11-2"><a href="#cb11-2" tabindex="-1"></a> <span class="fu">geom_bar</span>(<span class="at">show.legend =</span> <span class="cn">FALSE</span>) <span class="sc">+</span></span>
<span id="cb11-3"><a href="#cb11-3" tabindex="-1"></a> <span class="fu">scale_fill_civilytics</span>() <span class="sc">+</span></span>
<span id="cb11-4"><a href="#cb11-4" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">title =</span> <span class="st">&quot;Vehicle counts&quot;</span>, <span class="at">x =</span> <span class="cn">NULL</span>, <span class="at">y =</span> <span class="cn">NULL</span>) <span class="sc">+</span></span>
<span id="cb11-5"><a href="#cb11-5" tabindex="-1"></a> <span class="fu">theme_civilytics</span>(<span class="at">grid =</span> <span class="st">&quot;y&quot;</span>)</span>
<span id="cb11-6"><a href="#cb11-6" tabindex="-1"></a></span>
<span id="cb11-7"><a href="#cb11-7" tabindex="-1"></a>p2 <span class="ot">&lt;-</span> <span class="fu">ggplot</span>(mpg, <span class="fu">aes</span>(displ, hwy)) <span class="sc">+</span></span>
<span id="cb11-8"><a href="#cb11-8" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">colour =</span> civilytics_colors[<span class="st">&quot;navy_600&quot;</span>], <span class="at">size =</span> <span class="fl">1.5</span>) <span class="sc">+</span></span>
<span id="cb11-9"><a href="#cb11-9" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">title =</span> <span class="st">&quot;Displacement vs. MPG&quot;</span>, <span class="at">x =</span> <span class="st">&quot;Displacement (L)&quot;</span>, <span class="at">y =</span> <span class="st">&quot;Highway MPG&quot;</span>) <span class="sc">+</span></span>
<span id="cb11-10"><a href="#cb11-10" tabindex="-1"></a> <span class="fu">theme_civilytics</span>(<span class="at">grid =</span> <span class="st">&quot;y&quot;</span>)</span>
<span id="cb11-11"><a href="#cb11-11" tabindex="-1"></a></span>
<span id="cb11-12"><a href="#cb11-12" tabindex="-1"></a>logo <span class="ot">&lt;-</span> <span class="fu">make_logo_grob</span>()</span>
<span id="cb11-13"><a href="#cb11-13" tabindex="-1"></a>grid<span class="sc">::</span><span class="fu">grid.draw</span>(<span class="fu">add_logo_ga</span>(<span class="fu">list</span>(p1, p2), logo))</span></code></pre></div>
<img role="img" aria-label src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA2AAAAGwCAIAAABAUZH1AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdd1wT5x8H8OeyCWEvAQERkCUoIiAoThRx1F1bR6u12tba1qqtXXa3v2qrHdrhaGtd1dZR996KIipDBURBXOw9Q8bd749ASMJKMBDAz/vlH+ZyXL6X3D33vWcdJakqJQAAAAAAtViGDgAAAAAA2hckiAAAAACgBgkiAAAAAKhBgggAAAAAapAgAgAAAIAaJI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zWnXrhowQ2f1jpx8s8XatrSii006cS1bUH4qCnxnAu/97yxJEeXp0bN04F7Zjdyc2IYTIHsan1LWQcT0Hj/HoyJMHtT9adEMw7vvMIPN/dxXShBCm4vzxa+VRgxQV0/LHF4/cqj0KOd1GR7nXbI7O3vHLwdqeiSzLwYsPrR3vrHhv9KiJ/ssiFp/KoQlhqhP+/i9mzuIBDWU2LKuQT//86jVfY4oQRnxv/SuvfnShtKaTamHipbvyoT2bOxTkj7b9cuRh7VFFCT1e/v7bTyPsFJ8mK30Qc/JaeR8t0ip97E5LQpI/3vrzYLine truncated
<h2 id="other-utilities">Other utilities</h2>
<p>The package also includes helpers for public-sector data
analysis:</p>
<table>
<thead>
<tr>
<th align="left">Function</th>
<th align="left">Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>pretty_count()</code> /
<code>pretty_per()</code></td>
<td align="left">Format numbers and percentages</td>
</tr>
<tr>
<td align="left"><code>grade_level_to_num()</code></td>
<td align="left">Convert grade labels (KG, 01–12) to numeric</td>
</tr>
<tr>
<td align="left"><code>race_short_names()</code></td>
<td align="left">Standardize NCES race/ethnicity categories</td>
</tr>
<tr>
<td align="left"><code>get_fips()</code> /
<code>get_stabbr()</code></td>
<td align="left">State FIPS code lookups</td>
</tr>
<tr>
<td align="left"><code>clopper_pearson()</code> /
<code>agresti_coull_interval()</code></td>
<td align="left">Proportion confidence intervals</td>
</tr>
<tr>
<td align="left"><code>match_test()</code> /
<code>trunc_match()</code></td>
<td align="left">Fuzzy join diagnostics</td>
</tr>
<tr>
<td align="left"><code>perturb_count()</code> /
<code>random_round()</code></td>
<td align="left">Privacy-preserving data perturbation</td>
</tr>
</tbody>
</table>
<h2 id="maintaining-brand-assets">Maintaining brand assets</h2>
<p>Logo and brand mark files live in <code>inst/img/</code>. The package
ships both PNG (for ggplot2 raster composition) and SVG (for Quarto/HTML
output) variants:</p>
<table>
<thead>
<tr>
<th align="left">File</th>
<th align="left">Format</th>
<th align="left">Used by</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>civilytics-wordmark.png</code> /
<code>.svg</code></td>
<td align="left">Full “Civilytics” lockup</td>
<td align="left"><code>make_logo_grob(&quot;wordmark&quot;, &quot;light&quot;)</code>,
Quarto templates</td>
</tr>
<tr>
<td align="left"><code>civilytics-wordmark-reverse.png</code> /
<code>.svg</code></td>
<td align="left">Light-on-dark wordmark</td>
<td align="left"><code>make_logo_grob(&quot;wordmark&quot;, &quot;dark&quot;)</code>, dark
slides</td>
</tr>
<tr>
<td align="left"><code>civilytics-mark.png</code> /
<code>.svg</code></td>
<td align="left">Compact C-pulse icon</td>
<td align="left"><code>make_logo_grob(&quot;mark&quot;, &quot;light&quot;)</code></td>
</tr>
<tr>
<td align="left"><code>civilytics-mark-reverse.svg</code></td>
<td align="left">Light-on-dark mark</td>
<td align="left"><code>make_logo_grob(&quot;mark&quot;, &quot;dark&quot;)</code></td>
</tr>
<tr>
<td align="left"><code>civilytics-pulse.svg</code></td>
<td align="left">Standalone waveform glyph</td>
<td align="left">Quarto slide footer chrome</td>
</tr>
</tbody>
</table>
<p>To update the logos, replace the files in <code>inst/img/</code> with
new versions using the same filenames. The PNG files must be raster
images (the ggplot2 logo functions read them via
<code>png::readPNG()</code>). SVG files are passed through as-is by
Quarto and HTML templates.</p>
<p>After replacing files, re-render the README gallery to update the
screenshots:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" tabindex="-1"></a>devtools<span class="sc">::</span><span class="fu">load_all</span>()</span>
<span id="cb12-2"><a href="#cb12-2" tabindex="-1"></a>rmarkdown<span class="sc">::</span><span class="fu">render</span>(<span class="st">&quot;README.Rmd&quot;</span>)</span></code></pre></div>
</body>
</html>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 KiB

+2 -4
View File
@@ -2,7 +2,7 @@
title: "Who pays when rent outpaces wages?" title: "Who pays when rent outpaces wages?"
subtitle: "A 12-county analysis of cost-burdened renter households, 2019–2024." subtitle: "A 12-county analysis of cost-burdened renter households, 2019–2024."
author: author:
- name: "Jared Knowles" - name: "Civilytics Research"
affiliation: "Civilytics Consulting" affiliation: "Civilytics Consulting"
date: "2026-04-15" date: "2026-04-15"
abstract: | abstract: |
@@ -19,9 +19,7 @@ format:
toc: true toc: true
toc-location: right toc-location: right
typst: typst:
template-partials: template: ../typst/civilytics-typst.typ
- ../typst/typst-template.typ
- ../typst/typst-show.typ
pdf: pdf:
include-in-header: ../latex/civilytics.tex include-in-header: ../latex/civilytics.tex
include-before-body: ../latex/civilytics-title.tex include-before-body: ../latex/civilytics-title.tex
+2 -2
View File
@@ -55,11 +55,11 @@ Big idea goes here.
> Rent has outpaced wages in every county we studied. > Rent has outpaced wages in every county we studied.
Civilytics Consulting, 2026 Civilytics Research, 2026
## Thank you {.thank-you} ## Thank you {.thank-you}
Questions? Questions?
- jared@civilytics.com - jared@civilytics.com
- civilytics.com - civilytics.consulting
@@ -209,11 +209,7 @@ $code-color: #923D00 !default;
height: 2px; height: 2px;
background: var(--accent-600); background: var(--accent-600);
} }
.reveal ol { .reveal ol { list-style: decimal; }
list-style: decimal;
/* Room for two-digit markers in the bold mono face (#27) */
padding-left: 1.6em;
}
.reveal ol > li::marker { .reveal ol > li::marker {
color: var(--accent-600); color: var(--accent-600);
font-family: var(--font-mono); font-family: var(--font-mono);
@@ -751,7 +747,7 @@ img.civilytics-wordmark,
----------------------------------------------------------- */ ----------------------------------------------------------- */
.reveal .columns { .reveal .columns {
display: flex; display: flex;
gap: 1.5em; gap: 3em;
align-items: flex-start; align-items: flex-start;
margin: 0.25em 0; margin: 0.25em 0;
} }
@@ -759,11 +755,6 @@ img.civilytics-wordmark,
flex: 1; flex: 1;
min-width: 0; min-width: 0;
} }
/* Quarto writes width="60%" as an inline style; honor it (#26). Columns
without a width stay equal. */
.reveal .column[style*="width"] {
flex: 0 1 auto;
}
.reveal .column > :first-child { margin-top: 0; } .reveal .column > :first-child { margin-top: 0; }
/* Hand-rolled two-col for pandoc (non-Quarto) users */ /* Hand-rolled two-col for pandoc (non-Quarto) users */
@@ -1049,15 +1040,6 @@ body.civilytics-hide-chrome .slide-number {
.reveal section { break-inside: avoid; } .reveal section { break-inside: avoid; }
} }
/* reveal.js print-pdf zeroes section padding with !important, so the screen
padding is lost. Restore a smaller print value; 48px 72px pushed dense
slides onto extra pages (#25). */
html.print-pdf .reveal .slides section:not(.full-bleed):not(.stack),
html.reveal-print .reveal .slides section:not(.full-bleed):not(.stack) {
padding: 32px 56px !important;
box-sizing: border-box !important;
}
/* ----------------------------------------------------------- /* -----------------------------------------------------------
SMALL-SCREEN GUARDRAILS SMALL-SCREEN GUARDRAILS
Reveal scales slides, but the narrowest keep-legible margins. Reveal scales slides, but the narrowest keep-legible margins.
+3 -6
View File
@@ -2,16 +2,11 @@
% Replaces Quarto's default \maketitle. Uses values from YAML % Replaces Quarto's default \maketitle. Uses values from YAML
% (\thetitle, \theauthor, \thedate) plus an \ifabstract block. % (\thetitle, \theauthor, \thedate) plus an \ifabstract block.
% Guard: \thesubtitle is normally defined by civilytics.tex's subtitle
% capture; provide a fallback so this partial degrades gracefully if used
% without that preamble. See civilyticsR issue #13.
\providecommand{\thesubtitle}{}
\begin{titlepage} \begin{titlepage}
\pagecolor{paper} \pagecolor{paper}
\color{ink} \color{ink}
\vspace*{0.5in} \vspace*{0.5in}
{\sffamily\bfseries\scriptsize\color{ember}\MakeUppercase{— Civilytics Consulting}\par} {\sffamily\bfseries\scriptsize\color{ember}\MakeUppercase{— Civilytics Research}\par}
\vspace{12pt} \vspace{12pt}
{\displayfont\fontsize{32pt}{34pt}\selectfont\bfseries\color{ink}\thetitle\par} {\displayfont\fontsize{32pt}{34pt}\selectfont\bfseries\color{ink}\thetitle\par}
\vspace{8pt} \vspace{8pt}
@@ -38,6 +33,8 @@
% Pulse mark, in ember % Pulse mark, in ember
\begin{center} \begin{center}
\begin{tikzpicture}[overlay, remember picture]
\end{tikzpicture}
{\color{ember}\rule{40pt}{2pt}} {\color{ember}\rule{40pt}{2pt}}
\end{center} \end{center}
\end{titlepage} \end{titlepage}
+3 -26
View File
@@ -40,40 +40,17 @@
\color{ink} \color{ink}
% --- Fonts (require local install or fontspec lookup) --- % --- Fonts (require local install or fontspec lookup) ---
% Bold uses the family's native Bold weight (present in every Source Serif 4
% install). Do NOT hard-require a "SemiBold" face: the package installs no
% system fonts for the PDF path, and standard Source Serif 4 ships only
% Regular/Bold/Italic/BoldItalic. See civilyticsR issue #14.
\setmainfont{Source Serif 4}[ \setmainfont{Source Serif 4}[
UprightFont = *, UprightFont = *,
ItalicFont = * Italic, ItalicFont = * Italic,
BoldFont = * SemiBold,
BoldItalicFont = * SemiBold Italic,
Ligatures = TeX, Ligatures = TeX,
] ]
\setsansfont{Inter}[Ligatures = TeX] \setsansfont{Inter}[Ligatures = TeX]
\setmonofont{JetBrains Mono}[Scale = 0.92] \setmonofont{JetBrains Mono}[Scale = 0.92]
\newfontfamily\displayfont{Libre Franklin}[Ligatures = TeX] \newfontfamily\displayfont{Libre Franklin}[Ligatures = TeX]
% --- Subtitle capture ---
% Quarto/pandoc defines \subtitle (which appends to \@title) but never
% \thesubtitle, which the title page uses. This preamble is emitted before
% pandoc's \providecommand{\subtitle}, so our definition wins: capture the
% subtitle into \thesubtitle instead. See civilyticsR issue #13.
\makeatletter
\providecommand{\thesubtitle}{}
\def\subtitle#1{\renewcommand{\thesubtitle}{#1}}
\makeatother
% --- Use the Civilytics title page, not pandoc's default ---
% civilytics-title.tex (include-before-body) IS the title page. Quarto emits
% its default \maketitle + abstract *before* include-before-body, which would
% print a second, unstyled title. Neutralise both here, in the preamble
% (runs at \begin{document}, before the default title). The branded title page
% does not display the abstract. See civilyticsR issue #13.
\AtBeginDocument{%
\renewcommand{\maketitle}{}%
\renewenvironment{abstract}{\setbox0=\vbox\bgroup}{\egroup}%
}
% --- Hyperlinks --- % --- Hyperlinks ---
\hypersetup{ \hypersetup{
colorlinks = true, colorlinks = true,
@@ -100,7 +77,7 @@
\renewcommand{\footrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt}
\fancyhead[L]{\sffamily\scriptsize\color{ink3}\MakeUppercase{Civilytics Consulting}} \fancyhead[L]{\sffamily\scriptsize\color{ink3}\MakeUppercase{Civilytics Consulting}}
\fancyhead[R]{\sffamily\scriptsize\color{ink3}\thetitle} \fancyhead[R]{\sffamily\scriptsize\color{ink3}\thetitle}
\fancyfoot[L]{\sffamily\scriptsize\color{ink3}civilytics.com} \fancyfoot[L]{\sffamily\scriptsize\color{ink3}civilytics.consulting}
\fancyfoot[C]{\sffamily\scriptsize\color{ink3}\thepage} \fancyfoot[C]{\sffamily\scriptsize\color{ink3}\thepage}
\fancyfoot[R]{\sffamily\scriptsize\color{ink3}\textcopyright\ 2026} \fancyfoot[R]{\sffamily\scriptsize\color{ink3}\textcopyright\ 2026}
@@ -1,15 +1,9 @@
// ============================================================= // =============================================================
// Civilytics — Typst template partial for Quarto PDF (typst-template.typ). // Civilytics — Typst template for Quarto PDF
// Shipped as a Quarto template-partial (paired with typst-show.typ) rather
// than a full `template:` so Quarto keeps its own `definitions` partial —
// which defines Skylighting/token functions needed for syntax-highlighted
// code blocks. See civilyticsR issue #12.
// Usage in YAML: // Usage in YAML:
// format: // format:
// typst: // typst:
// template-partials: // template: quarto/typst/civilytics-typst.typ
// - quarto/typst/typst-template.typ
// - quarto/typst/typst-show.typ
// ============================================================= // =============================================================
#let paper-bg = rgb("#FAF7F2") #let paper-bg = rgb("#FAF7F2")
@@ -60,7 +54,7 @@
grid( grid(
columns: (1fr, auto, 1fr), columns: (1fr, auto, 1fr),
align: (left, center, right), align: (left, center, right),
[civilytics.com], [civilytics.consulting],
counter(page).display("1 / 1", both: true), counter(page).display("1 / 1", both: true),
[© 2026] [© 2026]
) )
@@ -164,7 +158,7 @@
if title != none { if title != none {
block[ block[
#set text(font: sans-stack, size: 8pt, weight: 600, fill: ember, tracking: 0.1em) #set text(font: sans-stack, size: 8pt, weight: 600, fill: ember, tracking: 0.1em)
#upper[— Civilytics Consulting] #upper[— Civilytics Research]
] ]
v(8pt) v(8pt)
block[ block[
@@ -235,3 +229,16 @@
doc doc
} }
// Quarto entry point
#show: doc => civilytics(
title: $title$,
$if(subtitle)$subtitle: $subtitle$,$endif$
$if(by-author)$authors: ($for(by-author)$"$it.name.literal$",$endfor$),$endif$
$if(date)$date: $date$,$endif$
$if(abstract)$abstract: [$abstract$],$endif$
toc: $if(toc)$true$else$false$endif$,
doc
)
$body$
-17
View File
@@ -1,17 +0,0 @@
// Civilytics — Typst show/entry partial for Quarto (typst-show.typ).
// Pairs with typst-template.typ. Quarto appends the rendered document body
// after this partial, so this file intentionally ends with the show rule and
// no trailing body token. (Do not write that token in a comment here: Quarto
// interpolates its template variables even inside comments.)
// Title/subtitle/date are wrapped in [ ] so arbitrary text (including words
// that are Typst keywords like "for"/"in") is treated as content, not code.
// See civilyticsR issue #12.
#show: doc => civilytics(
title: [$title$],
$if(subtitle)$subtitle: [$subtitle$],$endif$
$if(by-author)$authors: ($for(by-author)$"$it.name.literal$",$endfor$),$endif$
$if(date)$date: [$date$],$endif$
$if(abstract)$abstract: [$abstract$],$endif$
toc: $if(toc)$true$else$false$endif$,
doc
)
+9 -17
View File
@@ -8,37 +8,29 @@ add_logo(
plot, plot,
logo, logo,
margin_param = NULL, margin_param = NULL,
font_scale = 1, font_scale = 1.1,
position = c("bottom-right", "bottom-left", "top-right", "top-left"), position = c("bottom-right", "bottom-left", "top-right", "top-left")
logo_height = 0.5
) )
} }
\arguments{ \arguments{
\item{plot}{a ggplot2 object, or a patchwork composition} \item{plot}{a ggplot2 grob}
\item{logo}{a logo grob created by make_logo_grob()} \item{logo}{a logo grob created by make_logo_grob()}
\item{margin_param}{Optional numeric. Replaces the plot margin (in points) \item{margin_param}{a numeric specifying what margin to add or subtract to align the logo}
on the side next to the logo. `NULL` (default) leaves the plot's margins
alone.}
\item{font_scale}{Numeric. Multiplicative scaling factor applied to the \item{font_scale}{Numeric. Multiplicative scaling factor applied to text
base text size before composing. Default `1` leaves typography unchanged.} sizes before composing the plot with the logo. Default `1.1` inflates
text by ~10 \% to compensate for the viewport shrinkage caused by
[gridExtra::arrangeGrob()]. Set to `1` to disable.}
\item{position}{Character. Corner placement for the logo: `"bottom-right"` \item{position}{Character. Corner placement for the logo: `"bottom-right"`
(default), `"bottom-left"`, `"top-right"`, or `"top-left"`. Controls (default), `"bottom-left"`, `"top-right"`, or `"top-left"`. Controls
whether the logo is placed above or below the plot.} whether the logo is placed above or below the plot.}
\item{logo_height}{Numeric. Height in inches of the band reserved for the
logo. Default `0.5`.}
} }
\value{ \value{
a grob with a logo attached to it ready to plot a grob with a logo attached to it ready to plot
} }
\description{ \description{
The logo gets its own band of reserved height (`logo_height`, in inches) Add a logo to a ggplot2 object
below or above the plot, so it cannot overlap the plot's caption or push
anything off the canvas. Patchwork compositions are converted with
[patchwork::patchworkGrob()] so every panel and the
[patchwork::plot_annotation()] survive.
} }
+3 -8
View File
@@ -10,8 +10,7 @@ add_logo_ga(
nrow = 1, nrow = 1,
widths = NULL, widths = NULL,
margin_param = NULL, margin_param = NULL,
font_scale = 1, font_scale = 1.1
logo_height = 0.5
) )
} }
\arguments{ \arguments{
@@ -23,14 +22,10 @@ add_logo_ga(
\item{widths}{an optional vector the same length as plot_list with the widths for each plot} \item{widths}{an optional vector the same length as plot_list with the widths for each plot}
\item{margin_param}{Optional number. Replaces the bottom plot margin (in points). \item{margin_param}{a number giving the adjustment up or down to help manually align logo and captions}
`NULL` (default) leaves plot margins alone.}
\item{font_scale}{Numeric. Multiplicative scaling factor applied to text \item{font_scale}{Numeric. Multiplicative scaling factor applied to text
sizes before composing. Default `1`. See [add_logo()] for details.} sizes before composing. Default `1.1`. See [add_logo()] for details.}
\item{logo_height}{Numeric. Height in inches of the band reserved for the
logo below the plots. Default `0.5`.}
} }
\value{ \value{
a grid object a grid object
+7 -33
View File
@@ -4,46 +4,20 @@
\alias{civilytics_load_fonts} \alias{civilytics_load_fonts}
\title{Load Civilytics brand fonts} \title{Load Civilytics brand fonts}
\usage{ \usage{
civilytics_load_fonts( civilytics_load_fonts()
force = FALSE,
showtext = getOption("civilytics.showtext", TRUE)
)
}
\arguments{
\item{force}{Logical. If \code{TRUE}, reload fonts even if they were already
loaded in this session. Default \code{FALSE}.}
\item{showtext}{Logical. Turn on \code{showtext::showtext_auto()} after
registering the fonts. Default is \code{getOption("civilytics.showtext", TRUE)}.}
} }
\value{ \value{
Invisibly returns \code{TRUE} if fonts were loaded, \code{FALSE} if skipped Invisibly returns `NULL`.
(already loaded and \code{force = FALSE}).
} }
\description{ \description{
Downloads Inter, Libre Franklin, Source Serif 4 and JetBrains Mono from Downloads Inter and Libre Franklin from Google Fonts via
Google Fonts via \code{sysfonts::font_add_google()}, then, unless [sysfonts::font_add_google()], then calls [showtext::showtext_auto()] so
\code{showtext = FALSE}, calls \code{showtext::showtext_auto()} so that all graphics that all graphics devices render text with those fonts. This is called
devices render text with those fonts. This is called automatically when the automatically when the package loads; use this function to retry if the
package loads; use this function to retry if the initial load failed (e.g., initial load failed (e.g., the machine was offline at load time).
the machine was offline at load time).
}
\details{
Subsequent calls within the same session are no-ops unless \code{force = TRUE}.
\strong{Using ragg.} \code{showtext::showtext_auto()} draws text at 96 dpi whatever the
device resolution, so on a \code{ragg::agg_png(res = 300)} device text comes out
at about a third of its requested size. For ragg, set
\code{options(civilytics.showtext = FALSE)} before loading the package, or call
\code{showtext::showtext_auto(FALSE)} afterwards. The brand fonts must then be
installed on the system, because ragg reads system fonts rather than the
ones registered through sysfonts.
} }
\examples{ \examples{
\dontrun{ \dontrun{
civilytics_load_fonts() civilytics_load_fonts()
# For ragg devices: register the fonts but leave showtext off
civilytics_load_fonts(force = TRUE, showtext = FALSE)
} }
} }
+4 -7
View File
@@ -10,8 +10,7 @@ civilytics_logo(
variant = c("light", "dark"), variant = c("light", "dark"),
position = c("bottom-right", "bottom-left", "top-right", "top-left"), position = c("bottom-right", "bottom-left", "top-right", "top-left"),
margin_param = NULL, margin_param = NULL,
font_scale = 1, font_scale = 1.1
logo_height = 0.5
) )
} }
\arguments{ \arguments{
@@ -29,11 +28,9 @@ civilytics_logo(
\item{margin_param}{Numeric or `NULL`. Manual margin adjustment passed to \item{margin_param}{Numeric or `NULL`. Manual margin adjustment passed to
[add_logo()].} [add_logo()].}
\item{font_scale}{Numeric. Multiplies the plot's base text size before \item{font_scale}{Numeric. Inflate text sizes by this factor to compensate
composing. Default `1` leaves typography unchanged.} for viewport shrinkage when composing with [gridExtra::arrangeGrob()].
Default `1.1` (~10 \% inflation). Set to `1` to disable.}
\item{logo_height}{Numeric. Height in inches of the band reserved for the
logo. Default `0.5`.}
} }
\value{ \value{
A grob (from [gridExtra::arrangeGrob()]) ready to draw with A grob (from [gridExtra::arrangeGrob()]) ready to draw with
+1 -2
View File
@@ -22,8 +22,7 @@ Plot a jpeg image as a raster
} }
\examples{ \examples{
\dontrun{ \dontrun{
# Supply a path to your own JPEG file img <- system.file("img","Knowles_Headshot_2019_good.jpg",package="civilytics")
img <- "my_photo.jpg"
plot_jpeg(img) plot_jpeg(img)
} }
} }
+10 -12
View File
@@ -6,26 +6,25 @@
\usage{ \usage{
style_flextable_civilytics( style_flextable_civilytics(
ft, ft,
header_bg = civilytics_colors[["navy_700"]], header_bg = "#2c3e50",
header_color = "white", header_color = "white",
title_fontsize = 14, title_fontsize = 14,
body_fontsize = 11, body_fontsize = 11,
font_name = "Arial", font_name = "Arial",
zebra = TRUE, zebra = TRUE,
zebra_bg = civilytics_colors[["paper_2"]], zebra_bg = "#f0f0eb",
outer_border_color = civilytics_colors[["rule_strong"]], outer_border_color = "#888888",
outer_border_width = 1, outer_border_width = 1,
inner_border_color = civilytics_colors[["rule"]], inner_border_color = "#cccccc",
inner_border_width = 0.5, inner_border_width = 0.5,
footer_fontsize = 9, footer_fontsize = 9,
footer_color = civilytics_colors[["ink_3"]] footer_color = "#555555"
) )
} }
\arguments{ \arguments{
\item{ft}{A [flextable::flextable()] object.} \item{ft}{A [flextable::flextable()] object.}
\item{header_bg}{Character. Header background fill. Default \item{header_bg}{Character. Header background fill. Default `"#2c3e50"`.}
`civilytics_colors[["navy_700"]]`.}
\item{header_color}{Character. Header text color. Default `"white"`.} \item{header_color}{Character. Header text color. Default `"white"`.}
@@ -41,15 +40,15 @@ title row, `i = 1`). Default `14`.}
Default `TRUE`. Safely skipped for tables with fewer than two body rows.} Default `TRUE`. Safely skipped for tables with fewer than two body rows.}
\item{zebra_bg}{Character. Fill color for striped (even) body rows. \item{zebra_bg}{Character. Fill color for striped (even) body rows.
Default `civilytics_colors[["paper_2"]]`.} Default `"#f0f0eb"`.}
\item{outer_border_color}{Character. Outer border color. Default \item{outer_border_color}{Character. Outer border color. Default
`civilytics_colors[["rule_strong"]]`.} `"#888888"`.}
\item{outer_border_width}{Numeric. Outer border width. Default `1`.} \item{outer_border_width}{Numeric. Outer border width. Default `1`.}
\item{inner_border_color}{Character. Inner horizontal border color (body). \item{inner_border_color}{Character. Inner horizontal border color (body).
Default `civilytics_colors[["rule"]]`.} Default `"#cccccc"`.}
\item{inner_border_width}{Numeric. Inner horizontal border width. Default \item{inner_border_width}{Numeric. Inner horizontal border width. Default
`0.5`.} `0.5`.}
@@ -57,8 +56,7 @@ Default `civilytics_colors[["rule"]]`.}
\item{footer_fontsize}{Numeric. Footer font size (applied only if a footer \item{footer_fontsize}{Numeric. Footer font size (applied only if a footer
part exists). Default `9`.} part exists). Default `9`.}
\item{footer_color}{Character. Footer text color. Default \item{footer_color}{Character. Footer text color. Default `"#555555"`.}
`civilytics_colors[["ink_3"]]`.}
} }
\value{ \value{
The styled [flextable::flextable()] object. The styled [flextable::flextable()] object.
+8 -10
View File
@@ -17,7 +17,7 @@ theme_civilytics(
accent = unname(civilytics_colors["ember_600"]), accent = unname(civilytics_colors["ember_600"]),
strip_color = unname(civilytics_colors["paper_2"]), strip_color = unname(civilytics_colors["paper_2"]),
grid = c("y", "x", "both", "none"), grid = c("y", "x", "both", "none"),
paper_bg = FALSE paper_bg = TRUE
) )
} }
\arguments{ \arguments{
@@ -56,12 +56,10 @@ to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).}
\item{grid}{Character. Which major gridlines to draw: `"y"` (default, \item{grid}{Character. Which major gridlines to draw: `"y"` (default,
horizontal only), `"x"` (vertical only), `"both"`, or `"none"`.} horizontal only), `"x"` (vertical only), `"both"`, or `"none"`.}
\item{paper_bg}{Logical. If `TRUE`, fill the plot and panel backgrounds \item{paper_bg}{Logical. If `TRUE` (default), fill the plot and panel
with the warm `paper` color (Civilytics cream). Default is `FALSE` backgrounds with the warm `paper` color. Set to `FALSE` for a
(transparent) so that figures composite cleanly onto any background. transparent background (useful for slides or overlay on colored
Set to `TRUE` for the branded cream canvas. Note: a transparent device surfaces).}
background (e.g., `dev = "ragg_png"`, `dev.args = list(background =
"transparent")`) is also needed for fully-transparent PNG exports.}
} }
\value{ \value{
A complete ggplot2 [ggplot2::theme()] object. A complete ggplot2 [ggplot2::theme()] object.
@@ -107,7 +105,7 @@ shrinkage.
\dontrun{ \dontrun{
library(ggplot2) library(ggplot2)
# Default — transparent background for embedding # Default editorial theme
ggplot(mpg, aes(displ, hwy)) + ggplot(mpg, aes(displ, hwy)) +
geom_point() + geom_point() +
theme_civilytics() theme_civilytics()
@@ -118,10 +116,10 @@ ggplot(mpg, aes(displ, hwy, colour = class)) +
scale_color_civilytics() + scale_color_civilytics() +
theme_civilytics(grid = "both") theme_civilytics(grid = "both")
# Branded cream background (opt-in) # Transparent background for embedding
ggplot(mpg, aes(displ, hwy)) + ggplot(mpg, aes(displ, hwy)) +
geom_point() + geom_point() +
theme_civilytics(paper_bg = TRUE) theme_civilytics(paper_bg = FALSE)
# Larger text for poster or display # Larger text for poster or display
ggplot(mpg, aes(displ, hwy)) + ggplot(mpg, aes(displ, hwy)) +
+4 -4
View File
@@ -56,10 +56,10 @@ to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).}
\item{grid}{Character. Which major gridlines to draw: `"y"` (default, \item{grid}{Character. Which major gridlines to draw: `"y"` (default,
horizontal only), `"x"` (vertical only), `"both"`, or `"none"`.} horizontal only), `"x"` (vertical only), `"both"`, or `"none"`.}
\item{paper_bg}{Logical. If `TRUE`, fill the plot and panel backgrounds \item{paper_bg}{Logical. If `TRUE` (default), fill the plot and panel
with the warm `paper` color (Civilytics cream). Default is `FALSE` backgrounds with the warm `paper` color. Set to `FALSE` for a
(transparent) so that figures composite cleanly onto any background. transparent background (useful for slides or overlay on colored
Set to `TRUE` for the branded cream canvas.} surfaces).}
} }
\value{ \value{
A complete ggplot2 [ggplot2::theme()] object. A complete ggplot2 [ggplot2::theme()] object.
+4 -4
View File
@@ -52,10 +52,10 @@ design system.}
\item{strip_color}{Character. Hex code for facet strip background. Defaults \item{strip_color}{Character. Hex code for facet strip background. Defaults
to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).} to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).}
\item{paper_bg}{Logical. If `TRUE`, fill the plot and panel backgrounds \item{paper_bg}{Logical. If `TRUE` (default), fill the plot and panel
with the warm `paper` color (Civilytics cream). Default is `FALSE` backgrounds with the warm `paper` color. Set to `FALSE` for a
(transparent) so that figures composite cleanly onto any background. transparent background (useful for slides or overlay on colored
Set to `TRUE` for the branded cream canvas.} surfaces).}
} }
\value{ \value{
A complete ggplot2 [ggplot2::theme()] object. A complete ggplot2 [ggplot2::theme()] object.
+4 -4
View File
@@ -52,10 +52,10 @@ design system.}
\item{strip_color}{Character. Hex code for facet strip background. Defaults \item{strip_color}{Character. Hex code for facet strip background. Defaults
to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).} to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).}
\item{paper_bg}{Logical. If `TRUE`, fill the plot and panel backgrounds \item{paper_bg}{Logical. If `TRUE` (default), fill the plot and panel
with the warm `paper` color (Civilytics cream). Default is `FALSE` backgrounds with the warm `paper` color. Set to `FALSE` for a
(transparent) so that figures composite cleanly onto any background. transparent background (useful for slides or overlay on colored
Set to `TRUE` for the branded cream canvas.} surfaces).}
} }
\value{ \value{
A complete ggplot2 [ggplot2::theme()] object. A complete ggplot2 [ggplot2::theme()] object.
+4 -4
View File
@@ -56,10 +56,10 @@ to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).}
\item{grid}{Character. Which major gridlines to draw: `"y"` (default, \item{grid}{Character. Which major gridlines to draw: `"y"` (default,
horizontal only), `"x"` (vertical only), `"both"`, or `"none"`.} horizontal only), `"x"` (vertical only), `"both"`, or `"none"`.}
\item{paper_bg}{Logical. If `TRUE`, fill the plot and panel backgrounds \item{paper_bg}{Logical. If `TRUE` (default), fill the plot and panel
with the warm `paper` color (Civilytics cream). Default is `FALSE` backgrounds with the warm `paper` color. Set to `FALSE` for a
(transparent) so that figures composite cleanly onto any background. transparent background (useful for slides or overlay on colored
Set to `TRUE` for the branded cream canvas.} surfaces).}
} }
\value{ \value{
A complete ggplot2 [ggplot2::theme()] object. A complete ggplot2 [ggplot2::theme()] object.
+4 -4
View File
@@ -52,10 +52,10 @@ design system.}
\item{strip_color}{Character. Hex code for facet strip background. Defaults \item{strip_color}{Character. Hex code for facet strip background. Defaults
to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).} to [civilytics_colors]`["paper_2"]` (`#F2EDE4`).}
\item{paper_bg}{Logical. If `TRUE`, fill the plot and panel backgrounds \item{paper_bg}{Logical. If `TRUE` (default), fill the plot and panel
with the warm `paper` color (Civilytics cream). Default is `FALSE` backgrounds with the warm `paper` color. Set to `FALSE` for a
(transparent) so that figures composite cleanly onto any background. transparent background (useful for slides or overlay on colored
Set to `TRUE` for the branded cream canvas.} surfaces).}
} }
\value{ \value{
A complete ggplot2 [ggplot2::theme()] object. A complete ggplot2 [ggplot2::theme()] object.
-46
View File
@@ -1,46 +0,0 @@
# Project journal
Append-only, newest first. **Entries are never edited** — the value of this file is
that it records what was believed at the time, including the parts that turned out
wrong. Where things stand *today* is in `STATUS.md`, which is generated.
Four lines per entry. The analysis belongs in the issue or the decision record; this
file carries the reasoning and the pointers.
- **Why** — the driver. The one line git cannot reconstruct later.
- **Obligates** — issues this change created elsewhere. Numbers, not prose.
- **Refs** — commits, issues, decision records.
---
## 2026-10-15 · packaging · default branch renamed to main; add_logo_ga band and showtext switch
**Why:** `Closes` keywords only fire on the default branch, so the rename came first; #28 and #29 finished the logo work, and #29 took the opt-out switch because changing the showtext default would alter published reports we cannot see from here.
**Obligates:** none; turning showtext off by default is a future decision if consumers allow it
**Refs:** #28, #29, f3ec052, 119aa7a, 7bc547a
## 2026-10-15 · logo · logo band, patchwork panels, brand table colors, reveal print fixes
**Why:** figures with captions were shipping clipped and patchwork figures lost panels (#20); the table default and reveal print/column bugs were off-brand or broken in published decks. Default changes (font_scale 1, brand table colors) alter existing output, so this is 0.3.2.
**Obligates:** PDF check of #25/#27 in another project (never rendered here)
**Refs:** #20, #21, #22, #24, #25, #26, #27, 4f697e2, d6e3ba2, 0561df4, dfcad3d
## 2026-08-24 · packaging · roborev exclusion patterns fixed; init review triaged
**Why:** roborev reviewed the init commit because `excluded_commit_patterns` are
substring matches and `chore:` never matches the `chore(packaging):` form the
cadence rule mandates — the commit convention was silently defeating its own
review filter. Two low findings came back; one was half-right, one rested on a
generator it could not see.
**Obligates:** —
**Refs:** cd1af67, roborev job 15
## 2026-08-23 · packaging · compass initialised, five workstreams defined
**Why:** the package had no tracking at all — one open issue, a NEWS changelog, and
no record of why anything was decided. Workstream boundaries follow how the code
actually goes stale, not the directory listing: colors stay with theme because the
scales are consumed by the themes, and packaging is its own stream so CI and
dependency drift file against something.
**Obligates:** #21, #22
**Refs:** 7cad98b, #20
-41
View File
@@ -1,41 +0,0 @@
# Project status
> Between the compass markers is generated. Edit the sources, not this.
<!-- compass:begin -->
<!-- compass:board -->
## Where this stands
Every issue that was open is closed, and the default branch is `main`. The 0.3.2 changes are all pushed: the logo and `add_logo_ga()` reserve their own band so captions are not clipped, patchwork figures keep every panel, flextable defaults use brand colors, and `civilytics_load_fonts()` has a switch for ragg users who do not want showtext. The showtext default is unchanged, so turning it off by default is a separate decision that depends on which reports rely on it. The reveal print fixes still need a look in a rendered PDF, which another project will do.
## Ready to work on next
_Nothing is open and unblocked._
## Workstreams
| Stream | Commits since | Open | Debt | Owes docs |
|---|---|---|---|---|
| Themes, palettes, and fonts | 1 | 0 | 0 | no |
| Logo and branded output composition | 1 | 0 | 0 | no |
| Quarto themes and publishing templates | 0 | 0 | 0 | no |
| Analysis and workflow helpers | 0 | 0 | 0 | no |
| Package infrastructure and release | 2 | 0 | 0 | no |
## CI
![R-CMD-check](https://gitea.civilytics.org/Civilytics/civilyticsR/actions/workflows/check.yaml/badge.svg?branch=main)
<details>
<summary>Dependency graph and detail</summary>
_Nothing blocks anything else, so there is no graph to draw._
- Marker: `c16e6cec` (2026-10-15)
- Commits since: 4
- Open issues: 0
</details>
<!-- compass:end -->
-107
View File
@@ -1,107 +0,0 @@
[project]
name = "civilytics"
forge = "Civilytics/civilyticsR"
[[workstream]]
id = "theme"
title = "Themes, palettes, and fonts"
paths = [
"R/theme.R",
"R/colors.R",
"R/fonts.R",
"tests/testthat/test_theme.R",
]
docs = [
"man/theme_civilytics*.Rd",
"man/scale_color_civilytics.Rd",
"man/scale_fill_civilytics.Rd",
"man/civilytics_pal*.Rd",
"man/civilytics_colors.Rd",
"man/civilytics_load_fonts.Rd",
"README.Rmd",
]
[[workstream]]
id = "logo"
title = "Logo and branded output composition"
paths = [
"R/logo.R",
"R/flextable.R",
"inst/img/**",
"tests/testthat/test_logo.R",
"tests/testthat/test_flextable.R",
]
docs = [
"man/*logo*.Rd",
"man/*flextable*.Rd",
"man/plot_jpeg.Rd",
"man/get_png.Rd",
"man/has_caption.Rd",
"man/measure_caption.Rd",
"README.Rmd",
]
[[workstream]]
id = "quarto"
title = "Quarto themes and publishing templates"
paths = [
"R/quarto.R",
"inst/quarto/**",
]
docs = [
"man/use_civilytics_*.Rd",
"man/quarto-helpers.Rd",
"inst/quarto/examples/*.qmd",
]
[[workstream]]
id = "helpers"
title = "Analysis and workflow helpers"
paths = [
"R/utils.R",
"R/prop_conf.R",
"R/join_utilities.R",
"R/db.R",
"R/notifications.R",
"tests/testthat/test_utils.R",
"tests/testthat/test_propint.R",
"tests/testthat/test_joins.R",
"tests/testthat/test_db.R",
"tests/testthat/test_notifications.R",
]
docs = [
"README.Rmd",
"NEWS.md",
]
[[workstream]]
id = "packaging"
title = "Package infrastructure and release"
paths = [
"DESCRIPTION",
"NAMESPACE",
"Makefile",
"Dockerfile",
".Rbuildignore",
".gitea/workflows/**",
"tests/testthat.R",
"AGENTS.md",
".roborev.toml",
]
docs = [
"NEWS.md",
"README.Rmd",
]
[roborev]
project_guidelines = [
"Brand colors come from `civilytics_colors`; never write a hex literal in theme, scale, logo, or table code.",
"No tidyverse dependency. Imports is base R plus ggplot2, grid/gridExtra, png/jpeg, stringr, stringdist, showtext/sysfonts, jsonlite. Reject dplyr, purrr, magrittr, tibble, and data.table; use base R idioms.",
"NAMESPACE is roxygen-generated. Declare imports with `@importFrom` in the roxygen block and re-run roxygen; never hand-edit NAMESPACE.",
"Themes default to a transparent background (`paper_bg = FALSE`) so plots composite onto any Quarto, Reveal, or Typst background. Making an opaque background the default is a regression, not a preference.",
"Theme functions thread `ink`/`paper`/`accent` into ggplot2 4.0's base-theme parameters rather than setting element colors ad hoc. ggplot2 >= 4.0 is a hard dependency, so use S7 `@` property access on plot and theme objects, not `$`.",
"User-facing progress goes through `message()` so callers can suppress it. No `cat()` or `print()` in package code.",
"Nothing personal or client-identifying is vendored into `inst/` -- brand assets only. Version 0.3.2 removed headshots for exactly this reason.",
"The camelCase exports (`countCleanr`, `dbSafeNames`, `simpleCap`, `waldInterval`, `countDots`, `countNA`, `findDots`, `nvals`) are frozen public API; do not rename them. New functions are snake_case.",
"`R/theme.R` and `R/logo.R` are long by design -- one file per surface, with dense roxygen. File length is not a finding in this package; flag a single function over roughly 80 lines instead.",
]
-12
View File
@@ -1,12 +0,0 @@
# Decisions
One file per decision, numbered and immutable. A decision that changes is superseded
by a new record, never edited in place — the old reasoning is the point.
The table below is **generated** by `compass:decide`. Do not hand-edit it.
<!-- compass:begin decisions -->
| # | Date | Decision | Status |
|---|---|---|---|
| — | — | *No decisions recorded yet.* | — |
<!-- compass:end decisions -->
-51
View File
@@ -1,51 +0,0 @@
library(civilytics)
library(ggplot2)
library(grid)
data(mtcars)
ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point() +
labs(title = "This is the title", subtitle = "More context.",
caption = "JEK made this for you.") +
theme_civilytics_dark(font_size = 16)
(ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point() +
labs(title = "This is the title", subtitle = "More context.",
caption = "JEK made this for you.") +
theme_civilytics_dark(font_size = 16)) |>
civilytics_logo(variant = "dark") |>
grid::grid.draw()
dev.off()
(ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point() +
labs(title = "This is the title", subtitle = "More context.",
caption = "JEK made this for you.") +
theme_civilytics_dark()) |>
civilytics_logo(variant = "dark") |>
grid::grid.draw()
dev.off()
(ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point() +
labs(title = "This is the title", subtitle = "More context.",
caption = "JEK made this for you.") +
theme_civilytics_dark(font_size = 14)) |>
civilytics_logo(variant = "dark") |>
grid::grid.draw()
dev.off()
(ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point() +
labs(title = "This is the title", subtitle = "More context.",
caption = "JEK made this for you.") +
theme_civilytics_dark(font_size = 16)) |>
civilytics_logo(variant = "dark", position = "top-right") |>
grid::grid.draw()
-18
View File
@@ -87,21 +87,3 @@ test_that("extra_height increases the exported PNG height", {
expect_gt(dim(png::readPNG(path_big))[1], dim(png::readPNG(path_small))[1]) expect_gt(dim(png::readPNG(path_big))[1], dim(png::readPNG(path_small))[1])
}) })
test_that("style_flextable_civilytics defaults come from civilytics_colors (#21)", {
defaults <- formals(style_flextable_civilytics)
expect_identical(eval(defaults$header_bg), civilytics_colors[["navy_700"]])
expect_identical(eval(defaults$zebra_bg), civilytics_colors[["paper_2"]])
expect_identical(eval(defaults$outer_border_color), civilytics_colors[["rule_strong"]])
expect_identical(eval(defaults$inner_border_color), civilytics_colors[["rule"]])
expect_identical(eval(defaults$footer_color), civilytics_colors[["ink_3"]])
})
test_that("style_flextable_civilytics paints the header with brand navy", {
skip_if_not_installed("flextable")
skip_if_not_installed("officer")
styled <- style_flextable_civilytics(flextable::flextable(head(mtcars, 3)))
header_fill <- unique(as.vector(styled$header$styles$cells$background.color$data))
expect_identical(toupper(header_fill), toupper(civilytics_colors[["navy_700"]]))
})
-50
View File
@@ -1,50 +0,0 @@
# civilytics_load_fonts() must not touch the network or global devices in tests:
# both sysfonts::font_add_google() and showtext::showtext_auto() are mocked.
with_font_mocks <- function(code, env = parent.frame()) {
calls <- new.env()
calls$showtext <- 0L
calls$google <- character()
old <- .cv_state$fonts_loaded
.cv_state$fonts_loaded <- FALSE
withr::defer(.cv_state$fonts_loaded <- old, envir = env)
testthat::local_mocked_bindings(
font_add_google = function(name, family = name, ...) {
calls$google <- c(calls$google, family)
},
.package = "sysfonts", .env = env
)
testthat::local_mocked_bindings(
showtext_auto = function(enable = TRUE) calls$showtext <- calls$showtext + 1L,
.package = "showtext", .env = env
)
calls
}
test_that("civilytics_load_fonts turns showtext on by default (#29)", {
skip_if_not_installed("withr")
calls <- with_font_mocks()
expect_true(civilytics_load_fonts())
expect_length(calls$google, 4)
expect_equal(calls$showtext, 1L)
})
test_that("showtext = FALSE registers fonts but leaves showtext off (#29)", {
skip_if_not_installed("withr")
calls <- with_font_mocks()
expect_true(civilytics_load_fonts(showtext = FALSE))
expect_length(calls$google, 4)
expect_equal(calls$showtext, 0L)
})
test_that("options(civilytics.showtext = FALSE) sets the default (#29)", {
skip_if_not_installed("withr")
calls <- with_font_mocks()
withr::local_options(civilytics.showtext = FALSE)
civilytics_load_fonts()
expect_equal(calls$showtext, 0L)
})
test_that("showtext must be a single TRUE or FALSE", {
expect_error(civilytics_load_fonts(showtext = NA), "showtext")
expect_error(civilytics_load_fonts(showtext = c(TRUE, FALSE)), "showtext")
})
-108
View File
@@ -28,111 +28,3 @@ test_that("stamp_logo_png validates its inputs", {
# invalid type is rejected by match.arg() before the file is touched # invalid type is rejected by match.arg() before the file is touched
expect_error(stamp_logo_png(tempfile(fileext = ".png"), type = "banner")) expect_error(stamp_logo_png(tempfile(fileext = ".png"), type = "banner"))
}) })
# --- civilytics_logo() layout (#20) ------------------------------------------
caption_plot <- function() {
ggplot2::ggplot(mtcars, ggplot2::aes(mpg, wt)) +
ggplot2::geom_point() +
ggplot2::labs(title = "Title",
caption = "Source: a reasonably long attribution line, 2021-22\nSecond line") +
theme_civilytics()
}
# The composed grob is a gtable, wrapped in a grobTree when the plot has a
# background fill.
composed_table <- function(composed) {
if (inherits(composed, "gtable")) composed else composed$children[[2]]
}
bottom_ink <- function(grob, width, height, rows = 2) {
path <- tempfile(fileext = ".png")
grDevices::png(path, width = width, height = height, units = "in", res = 100)
grid::grid.newpage()
grid::grid.draw(grob)
grDevices::dev.off()
img <- png::readPNG(path)
n <- dim(img)[1]
edge <- img[(n - rows + 1):n, , 1:3, drop = FALSE]
sum(edge < 0.5)
}
test_that("font_scale defaults to 1 everywhere", {
expect_identical(formals(add_logo)$font_scale, 1)
expect_identical(formals(add_logo_ga)$font_scale, 1)
expect_identical(formals(civilytics_logo)$font_scale, 1)
})
test_that("the logo band is reserved space that sums to the canvas", {
p <- caption_plot()
for (pos in c("bottom-right", "top-left")) {
composed <- suppressWarnings(civilytics_logo(p, position = pos, logo_height = 0.6))
heights <- composed_table(composed)$heights
expect_equal(length(heights), 2)
expect_true(any(grepl("null", as.character(heights))))
expect_true(any(grepl("0.6", as.character(heights))))
}
})
test_that("a caption is not clipped at the bottom edge at several canvas sizes", {
skip_on_cran()
p <- caption_plot()
for (w in c(8, 11, 16, 24)) {
h <- w * 0.64
ink <- bottom_ink(suppressWarnings(civilytics_logo(p, position = "top-right")), w, h)
expect_equal(ink, 0, info = paste("width", w))
}
})
test_that("patchwork compositions keep every panel", {
skip_if_not_installed("patchwork")
p1 <- ggplot2::ggplot(mtcars, ggplot2::aes(mpg, wt)) + ggplot2::geom_point()
p2 <- ggplot2::ggplot(mtcars, ggplot2::aes(hp, wt)) + ggplot2::geom_point()
pw <- p1 + p2 + patchwork::plot_annotation(title = "Both panels")
composed <- suppressWarnings(civilytics_logo(pw))
panel_grob <- composed_table(composed)$grobs[[1]]
n_panels <- sum(grepl("^panel", panel_grob$layout$name))
expect_gte(n_panels, 2)
})
test_that("the logo keeps its aspect ratio at any canvas width (#20)", {
skip_if_not_installed("ragg")
ink_aspect <- function(width, type) {
path <- tempfile(fileext = ".png")
ragg::agg_png(path, width = width, height = 0.5, units = "in", res = 200,
background = "transparent")
grid::grid.draw(ggplot2::ggplotGrob(make_logo_grob(type = type)))
grDevices::dev.off()
ink <- which(png::readPNG(path)[, , 4] > 0.05, arr.ind = TRUE)
diff(range(ink[, 2])) / diff(range(ink[, 1]))
}
for (type in c("wordmark", "mark")) {
aspects <- vapply(c(6, 11, 24), ink_aspect, numeric(1), type = type)
expect_lt(diff(range(aspects)) / mean(aspects), 0.03, label = type)
}
})
# --- add_logo_ga() layout (#28) ----------------------------------------------
test_that("add_logo_ga reserves a logo band instead of using negative margins", {
logo <- make_logo_grob()
composed <- add_logo_ga(list(caption_plot(), caption_plot()), logo, logo_height = 0.6)
heights <- composed_table(composed)$heights
expect_equal(length(heights), 2)
expect_true(any(grepl("null", as.character(heights))))
expect_true(any(grepl("0.6", as.character(heights))))
})
test_that("add_logo_ga does not clip captions at several canvas sizes", {
skip_on_cran()
logo <- make_logo_grob()
for (nrow in c(1, 2)) {
for (w in c(8, 11, 16, 24)) {
composed <- suppressWarnings(
add_logo_ga(list(caption_plot(), caption_plot()), logo, nrow = nrow)
)
ink <- bottom_ink(composed, w, w * 0.64)
expect_equal(ink, 0, info = paste("nrow", nrow, "width", w))
}
}
})
+1 -172
View File
@@ -1,173 +1,2 @@
# Tests for proportion confidence interval functions # test prop intervals
# --- clopper_pearson ---------------------------------------------------------
test_that("clopper_pearson returns a named numeric vector of length 3", {
result <- clopper_pearson(20, 40)
expect_type(result, "double")
expect_length(result, 3)
expect_named(result, c("low", "observed", "high"))
})
test_that("clopper_pearson observed matches num/den", {
result <- clopper_pearson(20, 40)
expect_equal(unname(result["observed"]), 20 / 40)
})
test_that("clopper_pearson matches binom.test in base R", {
# The implementation is documented as producing the same results as
# binom.test(), which uses the Clopper-Pearson method.
for (num in c(0, 1, 5, 20, 39, 40)) {
result <- clopper_pearson(num, 40)
bt <- binom.test(num, 40)$conf.int
expect_equal(unname(result["low"]), bt[1], tolerance = 1e-10)
expect_equal(unname(result["high"]), bt[2], tolerance = 1e-10)
}
})
test_that("clopper_pearson interval is valid (low <= observed <= high)", {
result <- clopper_pearson(5, 10)
expect_lte(result["low"], result["observed"])
expect_gte(result["high"], result["observed"])
})
test_that("clopper_pearson handles edge cases", {
# num = 0: lower bound should be exactly 0
zero_result <- clopper_pearson(0, 10)
expect_equal(unname(zero_result["low"]), 0, tolerance = 1e-15)
expect_gt(unname(zero_result["high"]), 0)
# Upper bound should match binom.test exactly
bt_zero <- binom.test(0, 10)$conf.int[2]
expect_equal(unname(zero_result["high"]), unname(bt_zero), tolerance = 1e-10)
# num = den: upper bound should be exactly 1 (observed is at the boundary)
full_result <- clopper_pearson(10, 10)
expect_equal(unname(full_result["high"]), 1, tolerance = 1e-15)
# Lower bound for all-successes case is well below observed (asymmetric interval)
bt_full <- binom.test(10, 10)$conf.int
expect_equal(unname(full_result["low"]), unname(bt_full[1]), tolerance = 1e-10)
})
test_that("clopper_pearson respects conf.level", {
wide <- clopper_pearson(20, 40, conf.level = 0.99)
narrow <- clopper_pearson(20, 40, conf.level = 0.80)
# Higher confidence level produces a wider interval
expect_gt(unname(wide["high"]) - unname(wide["low"]),
unname(narrow["high"]) - unname(narrow["low"]))
})
# --- z_univariate ------------------------------------------------------------
test_that("z_univariate returns a single numeric value", {
result <- z_univariate(0.13, 0.11, 2500)
expect_type(result, "double")
expect_length(result, 1)
})
test_that("z_univariate equals the formula by hand calculation", {
# z = (p_hat - p_0) / sqrt(p_0 * (1 - p_0) / n)
unit_prop <- 0.13
global_prop <- 0.11
unit_denom <- 2500
expected <- (unit_prop - global_prop) /
sqrt((global_prop * (1 - global_prop)) / unit_denom)
result <- z_univariate(unit_prop, global_prop, unit_denom)
expect_equal(result, expected, tolerance = 1e-12)
})
test_that("z_univariate is zero when proportions are equal", {
expect_equal(z_univariate(0.5, 0.5, 100), 0, tolerance = 1e-15)
})
test_that("z_univariate sign follows the direction of deviation", {
# When unit_prop > global_prop, z should be positive
expect_gt(z_univariate(0.2, 0.1, 100), 0)
# When unit_prop < global_prop, z should be negative
expect_lt(z_univariate(0.1, 0.2, 100), 0)
})
# --- waldInterval ------------------------------------------------------------
test_that("waldInterval returns a named numeric vector of length 2", {
result <- waldInterval(x = 20, n = 40)
expect_type(result, "double")
expect_length(result, 2)
expect_named(result, c("lwr", "upr"))
})
test_that("waldInterval matches documented example values", {
# The roxygen @examples comment says: waldInterval(x = 20, n = 40)
# returns approximately 0.345 and 0.655
result <- waldInterval(20, 40)
p_hat <- 20 / 40 # 0.5
se <- sqrt(p_hat * (1 - p_hat) / 40) # ~0.0791
z_crit <- qnorm(0.975) # ~1.96
expect_equal(unname(result["lwr"]), p_hat - z_crit * se, tolerance = 1e-12)
expect_equal(unname(result["upr"]), p_hat + z_crit * se, tolerance = 1e-12)
})
test_that("waldInterval interval is centered on the sample proportion", {
result <- waldInterval(30, 50)
midpoint <- (unname(result["lwr"]) + unname(result["upr"])) / 2
expect_equal(midpoint, 30 / 50, tolerance = 1e-12)
})
test_that("waldInterval respects conf.level", {
wide <- waldInterval(20, 40, conf.level = 0.99)
narrow <- waldInterval(20, 40, conf.level = 0.80)
expect_gt(unname(wide["upr"]) - unname(wide["lwr"]),
unname(narrow["upr"]) - unname(narrow["lwr"]))
})
# --- agresti_coull_interval --------------------------------------------------
test_that("agresti_coull_interval returns a named numeric vector of length 3", {
result <- agresti_coull_interval(20, 40)
expect_type(result, "double")
expect_length(result, 3)
expect_named(result, c("low", "observed", "high"))
})
test_that("agresti_coull_interval observed matches num/den", {
result <- agresti_coull_interval(20, 40)
expect_equal(unname(result["observed"]), 20 / 40)
})
test_that("agresti_coull_interval interval is valid (low <= observed <= high)", {
result <- agresti_coull_interval(15, 30)
expect_lte(result["low"], result["observed"])
expect_gte(result["high"], result["observed"])
})
test_that("agresti_coull_interval matches manual formula calculation", {
num <- 20
den <- 40
conf_level <- 0.95
z <- qnorm(1 - (1 - conf_level) / 2)
n_tilde <- den + z^2
p_tilde <- (num + z^2 / 2) / n_tilde
margin <- z * sqrt(p_tilde * (1 - p_tilde) / n_tilde)
result <- agresti_coull_interval(num, den, conf.level = conf_level)
expect_equal(unname(result["low"]), p_tilde - margin, tolerance = 1e-12)
expect_equal(unname(result["high"]), p_tilde + margin, tolerance = 1e-12)
})
test_that("agresti_coull_interval respects conf.level", {
wide <- agresti_coull_interval(20, 40, conf.level = 0.99)
narrow <- agresti_coull_interval(20, 40, conf.level = 0.80)
expect_gt(unname(wide["high"]) - unname(wide["low"]),
unname(narrow["high"]) - unname(narrow["low"]))
})
+1 -6
View File
@@ -133,13 +133,8 @@ test_that("theme_civilytics uses brand ink color for text", {
expect_equal(th$text$colour, unname(civilytics_colors["ink"])) expect_equal(th$text$colour, unname(civilytics_colors["ink"]))
}) })
test_that("theme_civilytics has transparent background by default", { test_that("theme_civilytics uses brand paper color for plot background", {
th <- theme_civilytics() th <- theme_civilytics()
expect_true(is.na(th$plot.background$fill))
})
test_that("theme_civilytics uses brand paper color when paper_bg = TRUE", {
th <- theme_civilytics(paper_bg = TRUE)
expect_equal(th$plot.background$fill, unname(civilytics_colors["paper"])) expect_equal(th$plot.background$fill, unname(civilytics_colors["paper"]))
}) })
+1 -187
View File
@@ -65,193 +65,7 @@ test_that("na_sum quiet=TRUE suppresses the message", {
}) })
context("Test Utilities - Postcode Lookup")
# --- postcode_lookup -------------------------------------------------------
# Build a lookup that mirrors the internal implementation:
# state.name + "District of Columbia" + "Puerto Rico"
map_name <- c(state.name, "District of Columbia", "Puerto Rico")
map_abb <- c(state.abb, "DC", "PR")
lookup_ref <- function(x) {
map_abb[match(as.character(x), map_name)]
}
test_that("postcode_lookup returns correct abbreviations for known states", {
expect_equal(postcode_lookup("Montana"), lookup_ref("Montana"))
expect_equal(postcode_lookup("Texas"), lookup_ref("Texas"))
expect_equal(postcode_lookup("New York"), lookup_ref("New York"))
expect_equal(postcode_lookup("California"), lookup_ref("California"))
})
test_that("postcode_lookup handles DC and Puerto Rico", {
# These are not in state.name/state.abb but should still resolve.
expect_equal(postcode_lookup("District of Columbia"), "DC")
expect_equal(postcode_lookup("Puerto Rico"), "PR")
})
test_that("postcode_lookup is vectorized", {
states <- c("Montana", "Texas", "California", "Florida")
result <- postcode_lookup(states)
expected <- lookup_ref(states)
expect_equal(result, expected)
expect_length(result, length(states))
})
test_that("postcode_lookup returns NA for unknown state names", {
# match() returns NA when there is no match; the function propagates it.
result <- postcode_lookup("Atlantis")
expect_true(is.na(unname(result)))
})
test_that("postcode_lookup matches all built-in states", {
# Every entry in state.name should resolve to a valid abbreviation.
results <- postcode_lookup(state.name)
expected <- lookup_ref(state.name)
expect_equal(results, expected)
expect_false(any(is.na(results)))
})
context("Test Utilities - Race Short Names")
# --- race_short_names -------------------------------------------------------
# A reference implementation mirroring the function logic for cross-checking.
race_ref <- function(x) {
x <- as.character(x)
x[x %in% c("Black", "Black Or African American", "Black or African American",
"African American")] <- "black"
x[x %in% c("Hispanic", "Hispanic Or Latino", "Hispanic or Latino")] <- "hisp_lat"
x[x %in% c("White", "white", "White and Not Hispanic")] <- "white"
x[x %in% c("Asian", "Asian American")] <- "asian"
x[x %in% c("Two Or More Races", "Two or More Races")] <- "two_or_more"
x[x %in% c("Native Hawaiian Or Other Pacific Islander",
"Native Hawaiian or Other Pacific Islander",
"Native Hawaiian Pacific Islander")] <- "native_haw"
x[x %in% c("American Indian", "American Indian Or Alaska Native",
"American Indian or Alaska Native", "American Indian or Native Alaskan")] <- "amind"
x[x %in% c("Not Reported")] <- "other"
x
}
test_that("race_short_names returns character vector of same length", {
input <- c("Black", "Hispanic Or Latino", "White")
result <- race_short_names(input)
expect_type(result, "character")
expect_length(result, length(input))
})
test_that("race_short_names maps all known categories correctly", {
# One representative from each category group.
input <- c(
"Black Or African American",
"Hispanic or Latino",
"White and Not Hispanic",
"Asian American",
"Two or More Races",
"Native Hawaiian or Other Pacific Islander",
"American Indian or Alaska Native",
"Not Reported"
)
expected <- c(
"black", "hisp_lat", "white", "asian",
"two_or_more", "native_haw", "amind", "other"
)
result <- race_short_names(input)
expect_equal(result, expected)
})
test_that("race_short_names coerces factors to character", {
input_factor <- factor(c("Black", "White", "Asian"))
result <- race_short_names(input_factor)
expect_type(result, "character")
expect_equal(result, c("black", "white", "asian"))
})
test_that("race_short_names passes through unrecognized values unchanged", {
input <- c("Black", "Some Other Category", "White")
result <- race_short_names(input)
# Unrecognized category should be returned as-is (lowercased by as.character).
expect_equal(result[2], "Some Other Category")
})
test_that("race_short_names handles empty input", {
result <- race_short_names(character(0))
expect_length(result, 0)
expect_type(result, "character")
})
test_that("race_short_names matches reference implementation across all categories",
{
# Exhaustive check: feed every variant string the function handles.
all_variants <- c(
"Black", "Black Or African American", "Black or African American", "African American",
"Hispanic", "Hispanic Or Latino", "Hispanic or Latino",
"White", "white", "White and Not Hispanic",
"Asian", "Asian American",
"Two Or More Races", "Two or More Races",
"Native Hawaiian Or Other Pacific Islander",
"Native Hawaiian or Other Pacific Islander",
"Native Hawaiian Pacific Islander",
"American Indian", "American Indian Or Alaska Native",
"American Indian or Alaska Native", "American Indian or Native Alaskan",
"Not Reported"
)
expect_equal(race_short_names(all_variants), race_ref(all_variants))
})
context("Test Utilities - Get FIPS")
# --- get_fips ---------------------------------------------------------------
test_that("get_fips errors gracefully when tidycensus is not installed", {
# When tidycensus is absent, the function should stop with an informative message.
if (!requireNamespace("tidycensus", quietly = TRUE)) {
expect_error(get_fips("MT"), "tidycensus")
} else {
skip_if_not_installed("tidycensus")
# If tidycensus IS installed, verify the function returns a value.
result <- get_fips("MT")
expect_type(result, "character")
expect_gt(length(result), 0)
}
})
test_that("get_fips returns a FIPS code for a valid state abbreviation", {
skip_if_not_installed("tidycensus")
result <- get_fips("MT")
# Montana's FIPS state code is "30"
expect_equal(result, "30")
})
test_that("get_stabbr returns a valid abbreviation", {
skip_if_not_installed("tidycensus")
result <- get_fips("CA")
# California's FIPS state code is "06"
expect_equal(result, "06")
})
context("Test Utilities - Pretty Count") context("Test Utilities - Pretty Count")