feat: bump title sizes, add font_scale to logo functions, ship SVGs
R-CMD-check / R CMD check (push) Successful in 3m36s
- Change rel_large default from 16/14 to 20/14 (~1.43x) to match the Civilytics editorial design system. Subtitle now renders at 1.0x base instead of 0.86x. - Switch axis.text to rel() sizing so all text elements cascade from the root font_size, enabling uniform scaling. - Add font_scale parameter (default 1.1) to civilytics_logo(), add_logo(), and add_logo_ga() — inflates text by ~10% before arrangeGrob composition to compensate for viewport shrinkage. - Ship SVG logo variants (mark, wordmark, pulse) in inst/img/ for Quarto/HTML templates. - Add "Maintaining brand assets" section to README documenting inst/img/ file inventory and update workflow. - Document full font size hierarchy in theme_civilytics() roxygen.
No files matched your search
@@ -46,17 +46,27 @@ get_png <- function(filename) {
|
|||||||
#' @param plot a ggplot2 grob
|
#' @param plot a ggplot2 grob
|
||||||
#' @param logo a logo grob created by make_logo_grob()
|
#' @param logo a logo grob created by make_logo_grob()
|
||||||
#' @param margin_param a numeric specifying what margin to add or subtract to align the logo
|
#' @param margin_param a numeric specifying what margin to add or subtract to align the logo
|
||||||
|
#' @param font_scale Numeric. Multiplicative scaling factor applied to text
|
||||||
|
#' 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.
|
||||||
#'
|
#'
|
||||||
#' @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) {
|
add_logo <- function(plot, logo, margin_param = NULL, font_scale = 1.1) {
|
||||||
|
# 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) {
|
||||||
|
base_size <- plot$theme$text$size %||% 14
|
||||||
|
plot <- plot + ggplot2::theme(
|
||||||
|
text = ggplot2::element_text(size = base_size * font_scale)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if(has_caption(plot)) {
|
if(has_caption(plot)) {
|
||||||
# convert the caption size to a negative number and on the "pt" scale
|
|
||||||
# p1$theme$plot.caption$size * 1.1
|
|
||||||
# Count the number of lines, which is this + 1
|
|
||||||
# For each line, we can add a certain negative space to align the logo
|
|
||||||
cap_lines <- measure_caption(plot)
|
cap_lines <- measure_caption(plot)
|
||||||
if (!is.null(margin_param)) {
|
if (!is.null(margin_param)) {
|
||||||
plot <- plot + theme(plot.margin = unit(c(7, 7, margin_param, 7), "pt"))
|
plot <- plot + theme(plot.margin = unit(c(7, 7, margin_param, 7), "pt"))
|
||||||
@@ -107,13 +117,15 @@ has_caption <- function(gg) {
|
|||||||
any(names(gg$labels) == "caption")
|
any(names(gg$labels) == "caption")
|
||||||
}
|
}
|
||||||
|
|
||||||
#' Add a logo to a ggplot2 object
|
#' Add a logo to multiple ggplot2 objects
|
||||||
#'
|
#'
|
||||||
#' @param plot_list a list containing ggplot2 objects
|
#' @param plot_list a list containing ggplot2 objects
|
||||||
#' @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 a number giving the adjustment up or down to help manually align logo and captions
|
#' @param margin_param a number giving the adjustment up or down to help manually align logo and captions
|
||||||
|
#' @param font_scale Numeric. Multiplicative scaling factor applied to text
|
||||||
|
#' sizes before composing. Default `1.1`. See [add_logo()] for details.
|
||||||
#'
|
#'
|
||||||
#' @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()
|
||||||
@@ -131,7 +143,18 @@ has_caption <- function(gg) {
|
|||||||
#' grid.draw(plot_and_logo)
|
#' grid.draw(plot_and_logo)
|
||||||
#' dev.off()
|
#' dev.off()
|
||||||
#' }
|
#' }
|
||||||
add_logo_ga <- function(plot_list, logo, nrow = 1, widths = NULL, margin_param = NULL) {
|
add_logo_ga <- function(plot_list, logo, nrow = 1, widths = NULL,
|
||||||
|
margin_param = NULL, font_scale = 1.1) {
|
||||||
|
# Inflate text sizes to compensate for viewport shrinkage
|
||||||
|
if (!is.null(font_scale) && font_scale != 1) {
|
||||||
|
plot_list <- lapply(plot_list, function(p) {
|
||||||
|
base_size <- p$theme$text$size %||% 14
|
||||||
|
p + ggplot2::theme(
|
||||||
|
text = ggplot2::element_text(size = base_size * font_scale)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
# Change position of logo depending on if plot has a caption
|
# Change position of logo depending on if plot has a caption
|
||||||
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"))
|
||||||
@@ -224,6 +247,9 @@ make_logo_grob <- function(type = c("wordmark", "mark"),
|
|||||||
#' [make_logo_grob()].
|
#' [make_logo_grob()].
|
||||||
#' @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. Inflate text sizes by this factor to compensate
|
||||||
|
#' for viewport shrinkage when composing with [gridExtra::arrangeGrob()].
|
||||||
|
#' Default `1.1` (~10 \% inflation). Set to `1` to disable.
|
||||||
#'
|
#'
|
||||||
#' @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()].
|
||||||
@@ -246,12 +272,20 @@ make_logo_grob <- function(type = c("wordmark", "mark"),
|
|||||||
#' theme_civilytics_dark()) |>
|
#' theme_civilytics_dark()) |>
|
||||||
#' civilytics_logo(variant = "dark", type = "mark") |>
|
#' civilytics_logo(variant = "dark", type = "mark") |>
|
||||||
#' grid.draw()
|
#' grid.draw()
|
||||||
|
#'
|
||||||
|
#' # Disable font inflation
|
||||||
|
#' (ggplot(mpg, aes(displ, hwy)) +
|
||||||
|
#' geom_point() +
|
||||||
|
#' theme_civilytics()) |>
|
||||||
|
#' civilytics_logo(font_scale = 1) |>
|
||||||
|
#' grid.draw()
|
||||||
#' }
|
#' }
|
||||||
civilytics_logo <- function(plot,
|
civilytics_logo <- function(plot,
|
||||||
type = c("wordmark", "mark"),
|
type = c("wordmark", "mark"),
|
||||||
variant = c("light", "dark"),
|
variant = c("light", "dark"),
|
||||||
margin_param = NULL) {
|
margin_param = NULL,
|
||||||
|
font_scale = 1.1) {
|
||||||
logo <- make_logo_grob(type = type, variant = variant)
|
logo <- make_logo_grob(type = type, variant = variant)
|
||||||
add_logo(plot, logo, margin_param = margin_param)
|
add_logo(plot, logo, margin_param = margin_param, font_scale = font_scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,8 @@
|
|||||||
#' @param rel_tiny Numeric. Scale factor for tiny text relative to `font_size`.
|
#' @param rel_tiny Numeric. Scale factor for tiny text relative to `font_size`.
|
||||||
#' Default `11/14`.
|
#' Default `11/14`.
|
||||||
#' @param rel_large Numeric. Scale factor for large text (titles) relative to
|
#' @param rel_large Numeric. Scale factor for large text (titles) relative to
|
||||||
#' `font_size`. Default `16/14`.
|
#' `font_size`. Default `20/14` (~1.43x), matching the Civilytics editorial
|
||||||
|
#' design system.
|
||||||
#' @param ink Character. Hex code for foreground/text color. Defaults to
|
#' @param ink Character. Hex code for foreground/text color. Defaults to
|
||||||
#' [civilytics_colors]`["ink"]` (`#0E1A2B`).
|
#' [civilytics_colors]`["ink"]` (`#0E1A2B`).
|
||||||
#' @param paper Character. Hex code for background color. Defaults to
|
#' @param paper Character. Hex code for background color. Defaults to
|
||||||
@@ -40,6 +41,26 @@
|
|||||||
#' transparent background (useful for slides or overlay on colored
|
#' transparent background (useful for slides or overlay on colored
|
||||||
#' surfaces).
|
#' surfaces).
|
||||||
#'
|
#'
|
||||||
|
#' @section Font size hierarchy:
|
||||||
|
#' All text sizes are derived from `font_size` using relative scale factors.
|
||||||
|
#' At the default `font_size = 14`:
|
||||||
|
#'
|
||||||
|
#' | Element | Scale factor | Default size |
|
||||||
|
#' |:--------|:-------------|:-------------|
|
||||||
|
#' | Plot title | `rel_large` (1.43x) | ~20 pt |
|
||||||
|
#' | Subtitle | 1.0x | 14 pt |
|
||||||
|
#' | Axis text (tick labels) | `rel_small` (0.86x) | ~12 pt |
|
||||||
|
#' | Axis titles | `rel_small` (0.86x) | ~12 pt |
|
||||||
|
#' | Legend text | `rel_small` (0.86x) | ~12 pt |
|
||||||
|
#' | Caption | `rel_tiny` (0.79x) | ~11 pt |
|
||||||
|
#' | Legend title | `rel_tiny` (0.79x) | ~11 pt |
|
||||||
|
#' | Strip text (facets) | `rel_small` (0.86x) | ~12 pt |
|
||||||
|
#'
|
||||||
|
#' To uniformly scale all text, change `font_size`. To adjust only the title
|
||||||
|
#' prominence, change `rel_large`. When using [civilytics_logo()] to add a
|
||||||
|
#' logo below the plot, pass `font_scale` to compensate for viewport
|
||||||
|
#' shrinkage.
|
||||||
|
#'
|
||||||
#' @return A complete ggplot2 [ggplot2::theme()] object.
|
#' @return A complete ggplot2 [ggplot2::theme()] object.
|
||||||
#' @export
|
#' @export
|
||||||
#'
|
#'
|
||||||
@@ -62,6 +83,11 @@
|
|||||||
#' ggplot(mpg, aes(displ, hwy)) +
|
#' ggplot(mpg, aes(displ, hwy)) +
|
||||||
#' geom_point() +
|
#' geom_point() +
|
||||||
#' theme_civilytics(paper_bg = FALSE)
|
#' theme_civilytics(paper_bg = FALSE)
|
||||||
|
#'
|
||||||
|
#' # Larger text for poster or display
|
||||||
|
#' ggplot(mpg, aes(displ, hwy)) +
|
||||||
|
#' geom_point() +
|
||||||
|
#' theme_civilytics(font_size = 18)
|
||||||
#' }
|
#' }
|
||||||
theme_civilytics <- function(
|
theme_civilytics <- function(
|
||||||
font_size = 14,
|
font_size = 14,
|
||||||
@@ -70,7 +96,7 @@ theme_civilytics <- function(
|
|||||||
line_size = 0.5,
|
line_size = 0.5,
|
||||||
rel_small = 12 / 14,
|
rel_small = 12 / 14,
|
||||||
rel_tiny = 11 / 14,
|
rel_tiny = 11 / 14,
|
||||||
rel_large = 16 / 14,
|
rel_large = 20 / 14,
|
||||||
ink = unname(civilytics_colors["ink"]),
|
ink = unname(civilytics_colors["ink"]),
|
||||||
paper = unname(civilytics_colors["paper"]),
|
paper = unname(civilytics_colors["paper"]),
|
||||||
accent = unname(civilytics_colors["ember_600"]),
|
accent = unname(civilytics_colors["ember_600"]),
|
||||||
@@ -132,7 +158,7 @@ theme_civilytics <- function(
|
|||||||
axis.line.y = ggplot2::element_blank(),
|
axis.line.y = ggplot2::element_blank(),
|
||||||
axis.text = ggplot2::element_text(
|
axis.text = ggplot2::element_text(
|
||||||
color = ink_2,
|
color = ink_2,
|
||||||
size = small_size
|
size = ggplot2::rel(rel_small)
|
||||||
),
|
),
|
||||||
axis.text.x = ggplot2::element_text(
|
axis.text.x = ggplot2::element_text(
|
||||||
margin = ggplot2::margin(t = small_size / 4),
|
margin = ggplot2::margin(t = small_size / 4),
|
||||||
@@ -249,7 +275,7 @@ theme_civilytics <- function(
|
|||||||
),
|
),
|
||||||
plot.title.position = "plot",
|
plot.title.position = "plot",
|
||||||
plot.subtitle = ggplot2::element_text(
|
plot.subtitle = ggplot2::element_text(
|
||||||
size = ggplot2::rel(rel_small),
|
size = ggplot2::rel(1),
|
||||||
color = ink_2,
|
color = ink_2,
|
||||||
hjust = 0,
|
hjust = 0,
|
||||||
vjust = 1,
|
vjust = 1,
|
||||||
@@ -307,7 +333,7 @@ theme_civilytics_dark <- function(
|
|||||||
line_size = 0.5,
|
line_size = 0.5,
|
||||||
rel_small = 12 / 14,
|
rel_small = 12 / 14,
|
||||||
rel_tiny = 11 / 14,
|
rel_tiny = 11 / 14,
|
||||||
rel_large = 16 / 14,
|
rel_large = 20 / 14,
|
||||||
ink = unname(civilytics_colors["paper"]),
|
ink = unname(civilytics_colors["paper"]),
|
||||||
paper = unname(civilytics_colors["navy_700"]),
|
paper = unname(civilytics_colors["navy_700"]),
|
||||||
accent = unname(civilytics_colors["ember_400"]),
|
accent = unname(civilytics_colors["ember_400"]),
|
||||||
@@ -359,7 +385,7 @@ theme_civilytics_slide <- function(
|
|||||||
line_size = 0.5,
|
line_size = 0.5,
|
||||||
rel_small = 12 / 14,
|
rel_small = 12 / 14,
|
||||||
rel_tiny = 11 / 14,
|
rel_tiny = 11 / 14,
|
||||||
rel_large = 16 / 14,
|
rel_large = 20 / 14,
|
||||||
ink = unname(civilytics_colors["ink"]),
|
ink = unname(civilytics_colors["ink"]),
|
||||||
paper = unname(civilytics_colors["paper"]),
|
paper = unname(civilytics_colors["paper"]),
|
||||||
accent = unname(civilytics_colors["ember_600"]),
|
accent = unname(civilytics_colors["ember_600"]),
|
||||||
|
|||||||
@@ -256,3 +256,30 @@ The package also includes helpers for public-sector data analysis:
|
|||||||
| `clopper_pearson()` / `agresti_coull_interval()` | Proportion confidence intervals |
|
| `clopper_pearson()` / `agresti_coull_interval()` | Proportion confidence intervals |
|
||||||
| `match_test()` / `trunc_match()` | Fuzzy join diagnostics |
|
| `match_test()` / `trunc_match()` | Fuzzy join diagnostics |
|
||||||
| `perturb_count()` / `random_round()` | Privacy-preserving data perturbation |
|
| `perturb_count()` / `random_round()` | Privacy-preserving data perturbation |
|
||||||
|
|
||||||
|
## Maintaining brand assets
|
||||||
|
|
||||||
|
Logo and brand mark files live in `inst/img/`. The package ships both
|
||||||
|
PNG (for ggplot2 raster composition) and SVG (for Quarto/HTML output)
|
||||||
|
variants:
|
||||||
|
|
||||||
|
| File | Format | Used by |
|
||||||
|
|:-----|:-------|:--------|
|
||||||
|
| `civilytics-wordmark.png` / `.svg` | Full "Civilytics" lockup | `make_logo_grob("wordmark", "light")`, Quarto templates |
|
||||||
|
| `civilytics-wordmark-reverse.png` / `.svg` | Light-on-dark wordmark | `make_logo_grob("wordmark", "dark")`, dark slides |
|
||||||
|
| `civilytics-mark.png` / `.svg` | Compact C-pulse icon | `make_logo_grob("mark", "light")` |
|
||||||
|
| `civilytics-mark-reverse.svg` | Light-on-dark mark | `make_logo_grob("mark", "dark")` |
|
||||||
|
| `civilytics-pulse.svg` | Standalone waveform glyph | Quarto slide footer chrome |
|
||||||
|
|
||||||
|
To update the logos, replace the files in `inst/img/` with new versions
|
||||||
|
using the same filenames. The PNG files must be raster images (the
|
||||||
|
ggplot2 logo functions read them via `png::readPNG()`). SVG files are
|
||||||
|
passed through as-is by Quarto and HTML templates.
|
||||||
|
|
||||||
|
After replacing files, re-render the README gallery to update the
|
||||||
|
screenshots:
|
||||||
|
|
||||||
|
```r
|
||||||
|
devtools::load_all()
|
||||||
|
rmarkdown::render("README.Rmd")
|
||||||
|
```
|
||||||
@@ -229,3 +229,30 @@ The package also includes helpers for public-sector data analysis:
|
|||||||
| `clopper_pearson()` / `agresti_coull_interval()` | Proportion confidence intervals |
|
| `clopper_pearson()` / `agresti_coull_interval()` | Proportion confidence intervals |
|
||||||
| `match_test()` / `trunc_match()` | Fuzzy join diagnostics |
|
| `match_test()` / `trunc_match()` | Fuzzy join diagnostics |
|
||||||
| `perturb_count()` / `random_round()` | Privacy-preserving data perturbation |
|
| `perturb_count()` / `random_round()` | Privacy-preserving data perturbation |
|
||||||
|
|
||||||
|
## Maintaining brand assets
|
||||||
|
|
||||||
|
Logo and brand mark files live in `inst/img/`. The package ships both
|
||||||
|
PNG (for ggplot2 raster composition) and SVG (for Quarto/HTML output)
|
||||||
|
variants:
|
||||||
|
|
||||||
|
| File | Format | Used by |
|
||||||
|
|:---|:---|:---|
|
||||||
|
| `civilytics-wordmark.png` / `.svg` | Full “Civilytics” lockup | `make_logo_grob("wordmark", "light")`, Quarto templates |
|
||||||
|
| `civilytics-wordmark-reverse.png` / `.svg` | Light-on-dark wordmark | `make_logo_grob("wordmark", "dark")`, dark slides |
|
||||||
|
| `civilytics-mark.png` / `.svg` | Compact C-pulse icon | `make_logo_grob("mark", "light")` |
|
||||||
|
| `civilytics-mark-reverse.svg` | Light-on-dark mark | `make_logo_grob("mark", "dark")` |
|
||||||
|
| `civilytics-pulse.svg` | Standalone waveform glyph | Quarto slide footer chrome |
|
||||||
|
|
||||||
|
To update the logos, replace the files in `inst/img/` with new versions
|
||||||
|
using the same filenames. The PNG files must be raster images (the
|
||||||
|
ggplot2 logo functions read them via `png::readPNG()`). SVG files are
|
||||||
|
passed through as-is by Quarto and HTML templates.
|
||||||
|
|
||||||
|
After replacing files, re-render the README gallery to update the
|
||||||
|
screenshots:
|
||||||
|
|
||||||
|
``` r
|
||||||
|
devtools::load_all()
|
||||||
|
rmarkdown::render("README.Rmd")
|
||||||
|
```
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" role="img" aria-label="Civilytics mark">
|
||||||
|
<rect width="100" height="100" fill="#0E1A2B"></rect>
|
||||||
|
<g fill="none" stroke="#FAF7F2" stroke-linecap="butt">
|
||||||
|
<path d="M 82.77 27.06 A 40 40 0 1 0 82.77 72.94" stroke-width="15"></path>
|
||||||
|
<path d="M 30 50 L 35 50 L 38 44 L 42 56 L 46 42 L 50 58 L 54 50 L 64 50" stroke-width="3.5" stroke-linecap="square"></path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 438 B |
@@ -0,0 +1,7 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" role="img" aria-label="Civilytics mark">
|
||||||
|
|
||||||
|
<g fill="none" stroke="#0E1A2B" stroke-linecap="butt">
|
||||||
|
<path d="M 82.77 27.06 A 40 40 0 1 0 82.77 72.94" stroke-width="15"></path>
|
||||||
|
<path d="M 30 50 L 35 50 L 38 44 L 42 56 L 46 42 L 50 58 L 54 50 L 64 50" stroke-width="3.5" stroke-linecap="square"></path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 385 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 14" role="img" aria-label="Civic pulse">
|
||||||
|
<path d="M0 8 L5 8 L8 3 L12 13 L16 1 L20 11 L23 8 L30 8" fill="none" stroke="#0E1A2B" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 264 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 558 160" role="img" aria-label="Civilytics">
|
||||||
|
<rect width="558" height="160" fill="#0E1A2B"></rect><path fill="#FAF7F2" d="M43.12 33.78Q50.18 33.78 56.17 35.68Q62.16 37.58 66.81 41.06Q71.46 44.53 74.42 49.23Q77.39 53.94 78.51 59.54Q79.07 61.89 78.68 62.56Q78.29 63.23 77.06 63.46L57.46 64.69Q56.22 64.69 55.89 64.18Q55.55 63.68 55.33 62.56Q54.43 57.63 51.91 54.33Q49.39 51.02 43.79 51.02Q37.52 51.02 33.77 56.57Q30.02 62.11 30.02 75.78Q30.02 89.66 33.43 95.21Q36.85 100.75 43.68 100.75Q49.28 100.75 53.59 97.9Q57.9 95.04 60.82 87.65Q61.38 86.3 63.95 86.75L77.95 89.55Q78.51 89.66 79.18 90.34Q79.86 91.01 79.52 93.25Q79.18 95.04 77.73 98.18Q76.27 101.31 73.58 104.95Q70.9 108.59 66.64 111.78Q62.38 114.98 56.5 117.05Q50.62 119.12 42.9 119.12Q30.91 119.12 22.01 113.46Q13.1 107.81 8.23 97.9Q3.36 87.98 3.36 75.33Q3.36 62.67 8.23 53.38Q13.1 44.08 22.06 38.93Q31.02 33.78 43.12 33.78Z M104.54 114.75Q104.54 116.54 103.64 117.27Q102.74 118 100.84 118L85.05 118Q83.37 118 82.75 117.33Q82.14 116.66 82.14 115.2L82.14 61.22Q82.14 58.64 84.26 58.64L102.52 58.64Q104.54 58.64 104.54 60.88ZM104.54 50.46Q104.54 53.71 100.84 53.71L85.05 53.71Q83.37 53.71 82.75 52.98Q82.14 52.26 82.14 50.8L82.14 37.47Q82.14 34.9 84.26 34.9L102.52 34.9Q104.54 34.9 104.54 37.25Z M166.51 58.64Q167.86 58.64 168.36 59.65Q168.86 60.66 168.42 61.89L146.58 115.2Q145.46 118 142.43 118L131.9 118Q128.88 118 127.76 115.2L106.03 61.89Q105.58 60.66 106.2 59.65Q106.82 58.64 108.16 58.64L127.09 58.64Q128.1 58.64 128.88 59.31Q129.66 59.98 130 60.88L139.86 86.75Q140.53 88.88 141.54 86.64L151.06 60.88Q151.5 59.98 152.23 59.31Q152.96 58.64 153.97 58.64L166.51 58.64Z M192.31 114.75Q192.31 116.54 191.42 117.27Q190.52 118 188.62 118L172.82 118Q171.14 118 170.53 117.33Q169.91 116.66 169.91 115.2L169.91 61.22Q169.91 58.64 172.04 58.64L190.3 58.64Q192.31 58.64 192.31 60.88ZM192.31 50.46Q192.31 53.71 188.62 53.71L172.82 53.71Q171.14 53.71 170.53 52.98Q169.91 52.26 169.91 50.8L169.91 37.47Q169.91 34.9 172.04 34.9L190.3 34.9Q192.31 34.9 192.31 37.25Z M219.01 114.75Q219.01 116.54 218.11 117.27Q217.22 118 215.31 118L199.41 118Q196.38 118 196.38 115.2L196.94 37.47Q196.94 34.9 199.07 34.9L216.99 34.9Q219.01 34.9 219.01 37.25Z M230.14 136.48Q226.66 136.48 225.26 136.03Q223.86 135.58 223.86 134.02L223.86 122.59Q223.86 121.92 224.54 121.19Q225.21 120.46 227 120.46L234.95 120.46Q236.86 120.46 238.42 119.9Q239.99 119.34 240.94 118.5Q241.9 117.66 242.29 116.6Q242.68 115.54 242.23 114.53L220.5 61.89Q220.06 60.66 220.67 59.65Q221.29 58.64 222.63 58.64L241.56 58.64Q242.57 58.64 243.35 59.31Q244.14 59.98 244.47 60.88L253.99 87.76Q254.33 88.77 254.89 88.82Q255.45 88.88 255.9 87.76L265.53 60.88Q265.98 59.98 266.7 59.31Q267.43 58.64 268.44 58.64L280.98 58.64Q282.33 58.64 282.89 59.65Q283.45 60.66 282.89 61.89L261.05 114.53Q258.14 121.58 255.28 125.9Q252.42 130.21 248.95 132.5Q245.48 134.8 240.94 135.64Q236.41 136.48 230.14 136.48Z M315.3 73.76Q313.84 73.76 313.84 75.22L313.84 96.72Q313.84 99.63 315.69 101.14Q317.54 102.66 321.68 102.66L326.5 102.66Q327.39 102.66 327.95 103.33Q328.51 104 328.51 104.9L328.4 113.86Q328.4 116.54 325.15 117.22Q322.69 117.55 320.17 117.72Q317.65 117.89 315.13 117.94Q312.61 118 310.03 118Q301.97 118 296.7 114.14Q291.44 110.27 291.44 103.1L291.44 75.78Q291.44 73.76 289.76 73.76L284.38 73.76Q281.7 73.76 281.7 71.3L281.7 60.77Q281.7 58.64 284.16 58.64L290.77 58.64Q292 58.64 292.11 57.3L293.9 40.72Q294.13 38.48 295.92 38.48L312.38 38.48Q314.51 38.48 314.51 40.94L314.51 57.3Q314.51 58.53 315.74 58.53L326.05 58.53Q328.51 58.53 328.51 60.66L328.51 71.3Q328.51 73.76 325.71 73.76Z M353.42 114.75Q353.42 116.54 352.52 117.27Q351.62 118 349.72 118L333.93 118Q332.25 118 331.63 117.33Q331.02 116.66 331.02 115.2L331.02 61.22Q331.02 58.64 333.14 58.64L351.4 58.64Q353.42 58.64 353.42 60.88ZM353.42 50.46Q353.42 53.71 349.72 53.71L333.93 53.71Q332.25 53.71 331.63 52.98Q331.02 52.26 331.02 50.8L331.02 37.47Q331.02 34.9 333.14 34.9L351.4 34.9Q353.42 34.9 353.42 37.25Z M386.38 57.52Q394.45 57.52 400.05 60.49Q405.65 63.46 408.9 67.82Q412.14 72.19 413.04 76.56Q413.82 79.36 411.02 79.47L395.68 80.26Q394.11 80.37 393.78 78.69Q393.55 77.23 392.99 75.61Q392.43 73.98 391.03 72.81Q389.63 71.63 386.94 71.63Q384.26 71.63 382.24 73.31Q380.22 74.99 379.1 78.63Q377.98 82.27 377.98 88.32Q377.98 94.48 379.22 98.23Q380.45 101.98 382.74 103.61Q385.04 105.23 388.18 105.23Q392.77 105.23 394.95 102.71Q397.14 100.19 399.26 96.38Q399.49 95.94 399.94 95.77Q400.38 95.6 401.5 95.82L412.03 97.84Q413.6 98.18 413.04 100.42Q412.59 102.54 410.91 105.74Q409.23 108.93 406.1 111.95Q402.96 114.98 398.09 117.05Q393.22 119.12 386.38 119.12Q377.42 119.12 370.42 115.26Q363.42 111.39 359.39 104.5Q355.36 97.62 355.36 88.54Q355.36 79.25 359.45 72.3Q363.54 65.36 370.54 61.44Q377.54 57.52 386.38 57.52Z M452.06 75.66Q450.38 73.76 447.69 72.14Q445 70.51 440.86 70.51Q437.94 70.51 435.82 71.52Q433.69 72.53 433.69 74.43Q433.69 75.22 434.42 76Q435.14 76.78 438.17 77.34L450.04 79.81Q460.46 81.94 464.66 87.2Q468.86 92.46 468.86 98.96Q468.86 105.46 465.27 109.94Q461.69 114.42 455.3 116.77QLine truncated
|
||||||
|
<path fill="none" stroke="#FAF7F2" stroke-width="5" stroke-linecap="square" stroke-linejoin="miter" d="M479.87199999999996 90 L489.87199999999996 90 L495.87199999999996 80 L503.87199999999996 104 L511.87199999999996 76 L519.872 102 L525.872 90 L547.872 90"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.0 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 558 160" role="img" aria-label="Civilytics">
|
||||||
|
<path fill="#0E1A2B" d="M43.12 33.78Q50.18 33.78 56.17 35.68Q62.16 37.58 66.81 41.06Q71.46 44.53 74.42 49.23Q77.39 53.94 78.51 59.54Q79.07 61.89 78.68 62.56Q78.29 63.23 77.06 63.46L57.46 64.69Q56.22 64.69 55.89 64.18Q55.55 63.68 55.33 62.56Q54.43 57.63 51.91 54.33Q49.39 51.02 43.79 51.02Q37.52 51.02 33.77 56.57Q30.02 62.11 30.02 75.78Q30.02 89.66 33.43 95.21Q36.85 100.75 43.68 100.75Q49.28 100.75 53.59 97.9Q57.9 95.04 60.82 87.65Q61.38 86.3 63.95 86.75L77.95 89.55Q78.51 89.66 79.18 90.34Q79.86 91.01 79.52 93.25Q79.18 95.04 77.73 98.18Q76.27 101.31 73.58 104.95Q70.9 108.59 66.64 111.78Q62.38 114.98 56.5 117.05Q50.62 119.12 42.9 119.12Q30.91 119.12 22.01 113.46Q13.1 107.81 8.23 97.9Q3.36 87.98 3.36 75.33Q3.36 62.67 8.23 53.38Q13.1 44.08 22.06 38.93Q31.02 33.78 43.12 33.78Z M104.54 114.75Q104.54 116.54 103.64 117.27Q102.74 118 100.84 118L85.05 118Q83.37 118 82.75 117.33Q82.14 116.66 82.14 115.2L82.14 61.22Q82.14 58.64 84.26 58.64L102.52 58.64Q104.54 58.64 104.54 60.88ZM104.54 50.46Q104.54 53.71 100.84 53.71L85.05 53.71Q83.37 53.71 82.75 52.98Q82.14 52.26 82.14 50.8L82.14 37.47Q82.14 34.9 84.26 34.9L102.52 34.9Q104.54 34.9 104.54 37.25Z M166.51 58.64Q167.86 58.64 168.36 59.65Q168.86 60.66 168.42 61.89L146.58 115.2Q145.46 118 142.43 118L131.9 118Q128.88 118 127.76 115.2L106.03 61.89Q105.58 60.66 106.2 59.65Q106.82 58.64 108.16 58.64L127.09 58.64Q128.1 58.64 128.88 59.31Q129.66 59.98 130 60.88L139.86 86.75Q140.53 88.88 141.54 86.64L151.06 60.88Q151.5 59.98 152.23 59.31Q152.96 58.64 153.97 58.64L166.51 58.64Z M192.31 114.75Q192.31 116.54 191.42 117.27Q190.52 118 188.62 118L172.82 118Q171.14 118 170.53 117.33Q169.91 116.66 169.91 115.2L169.91 61.22Q169.91 58.64 172.04 58.64L190.3 58.64Q192.31 58.64 192.31 60.88ZM192.31 50.46Q192.31 53.71 188.62 53.71L172.82 53.71Q171.14 53.71 170.53 52.98Q169.91 52.26 169.91 50.8L169.91 37.47Q169.91 34.9 172.04 34.9L190.3 34.9Q192.31 34.9 192.31 37.25Z M219.01 114.75Q219.01 116.54 218.11 117.27Q217.22 118 215.31 118L199.41 118Q196.38 118 196.38 115.2L196.94 37.47Q196.94 34.9 199.07 34.9L216.99 34.9Q219.01 34.9 219.01 37.25Z M230.14 136.48Q226.66 136.48 225.26 136.03Q223.86 135.58 223.86 134.02L223.86 122.59Q223.86 121.92 224.54 121.19Q225.21 120.46 227 120.46L234.95 120.46Q236.86 120.46 238.42 119.9Q239.99 119.34 240.94 118.5Q241.9 117.66 242.29 116.6Q242.68 115.54 242.23 114.53L220.5 61.89Q220.06 60.66 220.67 59.65Q221.29 58.64 222.63 58.64L241.56 58.64Q242.57 58.64 243.35 59.31Q244.14 59.98 244.47 60.88L253.99 87.76Q254.33 88.77 254.89 88.82Q255.45 88.88 255.9 87.76L265.53 60.88Q265.98 59.98 266.7 59.31Q267.43 58.64 268.44 58.64L280.98 58.64Q282.33 58.64 282.89 59.65Q283.45 60.66 282.89 61.89L261.05 114.53Q258.14 121.58 255.28 125.9Q252.42 130.21 248.95 132.5Q245.48 134.8 240.94 135.64Q236.41 136.48 230.14 136.48Z M315.3 73.76Q313.84 73.76 313.84 75.22L313.84 96.72Q313.84 99.63 315.69 101.14Q317.54 102.66 321.68 102.66L326.5 102.66Q327.39 102.66 327.95 103.33Q328.51 104 328.51 104.9L328.4 113.86Q328.4 116.54 325.15 117.22Q322.69 117.55 320.17 117.72Q317.65 117.89 315.13 117.94Q312.61 118 310.03 118Q301.97 118 296.7 114.14Q291.44 110.27 291.44 103.1L291.44 75.78Q291.44 73.76 289.76 73.76L284.38 73.76Q281.7 73.76 281.7 71.3L281.7 60.77Q281.7 58.64 284.16 58.64L290.77 58.64Q292 58.64 292.11 57.3L293.9 40.72Q294.13 38.48 295.92 38.48L312.38 38.48Q314.51 38.48 314.51 40.94L314.51 57.3Q314.51 58.53 315.74 58.53L326.05 58.53Q328.51 58.53 328.51 60.66L328.51 71.3Q328.51 73.76 325.71 73.76Z M353.42 114.75Q353.42 116.54 352.52 117.27Q351.62 118 349.72 118L333.93 118Q332.25 118 331.63 117.33Q331.02 116.66 331.02 115.2L331.02 61.22Q331.02 58.64 333.14 58.64L351.4 58.64Q353.42 58.64 353.42 60.88ZM353.42 50.46Q353.42 53.71 349.72 53.71L333.93 53.71Q332.25 53.71 331.63 52.98Q331.02 52.26 331.02 50.8L331.02 37.47Q331.02 34.9 333.14 34.9L351.4 34.9Q353.42 34.9 353.42 37.25Z M386.38 57.52Q394.45 57.52 400.05 60.49Q405.65 63.46 408.9 67.82Q412.14 72.19 413.04 76.56Q413.82 79.36 411.02 79.47L395.68 80.26Q394.11 80.37 393.78 78.69Q393.55 77.23 392.99 75.61Q392.43 73.98 391.03 72.81Q389.63 71.63 386.94 71.63Q384.26 71.63 382.24 73.31Q380.22 74.99 379.1 78.63Q377.98 82.27 377.98 88.32Q377.98 94.48 379.22 98.23Q380.45 101.98 382.74 103.61Q385.04 105.23 388.18 105.23Q392.77 105.23 394.95 102.71Q397.14 100.19 399.26 96.38Q399.49 95.94 399.94 95.77Q400.38 95.6 401.5 95.82L412.03 97.84Q413.6 98.18 413.04 100.42Q412.59 102.54 410.91 105.74Q409.23 108.93 406.1 111.95Q402.96 114.98 398.09 117.05Q393.22 119.12 386.38 119.12Q377.42 119.12 370.42 115.26Q363.42 111.39 359.39 104.5Q355.36 97.62 355.36 88.54Q355.36 79.25 359.45 72.3Q363.54 65.36 370.54 61.44Q377.54 57.52 386.38 57.52Z M452.06 75.66Q450.38 73.76 447.69 72.14Q445 70.51 440.86 70.51Q437.94 70.51 435.82 71.52Q433.69 72.53 433.69 74.43Q433.69 75.22 434.42 76Q435.14 76.78 438.17 77.34L450.04 79.81Q460.46 81.94 464.66 87.2Q468.86 92.46 468.86 98.96Q468.86 105.46 465.27 109.94Q461.69 114.42 455.3 116.77Q448.92 119.12 440.52 119.12Q429.77 119.12 422.6 115.5Line truncated
|
||||||
|
<path fill="none" stroke="#0E1A2B" stroke-width="5" stroke-linecap="square" stroke-linejoin="miter" d="M479.87199999999996 90 L489.87199999999996 90 L495.87199999999996 80 L503.87199999999996 104 L511.87199999999996 76 L519.872 102 L525.872 90 L547.872 90"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.9 KiB |
@@ -4,7 +4,7 @@
|
|||||||
\alias{add_logo}
|
\alias{add_logo}
|
||||||
\title{Add a logo to a ggplot2 object}
|
\title{Add a logo to a ggplot2 object}
|
||||||
\usage{
|
\usage{
|
||||||
add_logo(plot, logo, margin_param = NULL)
|
add_logo(plot, logo, margin_param = NULL, font_scale = 1.1)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{plot}{a ggplot2 grob}
|
\item{plot}{a ggplot2 grob}
|
||||||
@@ -12,6 +12,11 @@ add_logo(plot, logo, margin_param = NULL)
|
|||||||
\item{logo}{a logo grob created by make_logo_grob()}
|
\item{logo}{a logo grob created by make_logo_grob()}
|
||||||
|
|
||||||
\item{margin_param}{a numeric specifying what margin to add or subtract to align the logo}
|
\item{margin_param}{a numeric specifying what margin to add or subtract to align the logo}
|
||||||
|
|
||||||
|
\item{font_scale}{Numeric. Multiplicative scaling factor applied to text
|
||||||
|
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.}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
a grob with a logo attached to it ready to plot
|
a grob with a logo attached to it ready to plot
|
||||||
|
|||||||
@@ -2,9 +2,16 @@
|
|||||||
% Please edit documentation in R/logo.R
|
% Please edit documentation in R/logo.R
|
||||||
\name{add_logo_ga}
|
\name{add_logo_ga}
|
||||||
\alias{add_logo_ga}
|
\alias{add_logo_ga}
|
||||||
\title{Add a logo to a ggplot2 object}
|
\title{Add a logo to multiple ggplot2 objects}
|
||||||
\usage{
|
\usage{
|
||||||
add_logo_ga(plot_list, logo, nrow = 1, widths = NULL, margin_param = NULL)
|
add_logo_ga(
|
||||||
|
plot_list,
|
||||||
|
logo,
|
||||||
|
nrow = 1,
|
||||||
|
widths = NULL,
|
||||||
|
margin_param = NULL,
|
||||||
|
font_scale = 1.1
|
||||||
|
)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{plot_list}{a list containing ggplot2 objects}
|
\item{plot_list}{a list containing ggplot2 objects}
|
||||||
@@ -16,12 +23,15 @@ add_logo_ga(plot_list, logo, nrow = 1, widths = NULL, margin_param = NULL)
|
|||||||
\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}{a number giving the adjustment up or down to help manually align logo and captions}
|
\item{margin_param}{a number giving the adjustment up or down to help manually align logo and captions}
|
||||||
|
|
||||||
|
\item{font_scale}{Numeric. Multiplicative scaling factor applied to text
|
||||||
|
sizes before composing. Default `1.1`. See [add_logo()] for details.}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
a grid object
|
a grid object
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Add a logo to a ggplot2 object
|
Add a logo to multiple ggplot2 objects
|
||||||
}
|
}
|
||||||
\note{
|
\note{
|
||||||
The resulting object needs to be drawn to the screen using grid.draw()
|
The resulting object needs to be drawn to the screen using grid.draw()
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ civilytics_logo(
|
|||||||
plot,
|
plot,
|
||||||
type = c("wordmark", "mark"),
|
type = c("wordmark", "mark"),
|
||||||
variant = c("light", "dark"),
|
variant = c("light", "dark"),
|
||||||
margin_param = NULL
|
margin_param = NULL,
|
||||||
|
font_scale = 1.1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
@@ -22,6 +23,10 @@ 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. Inflate text sizes by this factor to compensate
|
||||||
|
for viewport shrinkage when composing with [gridExtra::arrangeGrob()].
|
||||||
|
Default `1.1` (~10 \% inflation). Set to `1` to disable.}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
A grob (from [gridExtra::arrangeGrob()]) ready to draw with
|
A grob (from [gridExtra::arrangeGrob()]) ready to draw with
|
||||||
@@ -59,5 +64,12 @@ library(ggplot2); library(grid)
|
|||||||
theme_civilytics_dark()) |>
|
theme_civilytics_dark()) |>
|
||||||
civilytics_logo(variant = "dark", type = "mark") |>
|
civilytics_logo(variant = "dark", type = "mark") |>
|
||||||
grid.draw()
|
grid.draw()
|
||||||
|
|
||||||
|
# Disable font inflation
|
||||||
|
(ggplot(mpg, aes(displ, hwy)) +
|
||||||
|
geom_point() +
|
||||||
|
theme_civilytics()) |>
|
||||||
|
civilytics_logo(font_scale = 1) |>
|
||||||
|
grid.draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 165 KiB |
|
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 161 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 97 KiB |
@@ -11,7 +11,7 @@ theme_civilytics(
|
|||||||
line_size = 0.5,
|
line_size = 0.5,
|
||||||
rel_small = 12/14,
|
rel_small = 12/14,
|
||||||
rel_tiny = 11/14,
|
rel_tiny = 11/14,
|
||||||
rel_large = 16/14,
|
rel_large = 20/14,
|
||||||
ink = unname(civilytics_colors["ink"]),
|
ink = unname(civilytics_colors["ink"]),
|
||||||
paper = unname(civilytics_colors["paper"]),
|
paper = unname(civilytics_colors["paper"]),
|
||||||
accent = unname(civilytics_colors["ember_600"]),
|
accent = unname(civilytics_colors["ember_600"]),
|
||||||
@@ -38,7 +38,8 @@ Default `"Libre Franklin"` (loaded via showtext).}
|
|||||||
Default `11/14`.}
|
Default `11/14`.}
|
||||||
|
|
||||||
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
|
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
|
||||||
`font_size`. Default `16/14`.}
|
`font_size`. Default `20/14` (~1.43x), matching the Civilytics editorial
|
||||||
|
design system.}
|
||||||
|
|
||||||
\item{ink}{Character. Hex code for foreground/text color. Defaults to
|
\item{ink}{Character. Hex code for foreground/text color. Defaults to
|
||||||
[civilytics_colors]`["ink"]` (`#0E1A2B`).}
|
[civilytics_colors]`["ink"]` (`#0E1A2B`).}
|
||||||
@@ -78,6 +79,28 @@ Brand fonts (Inter for UI text, Libre Franklin for titles) are loaded
|
|||||||
automatically via [showtext] when the package is attached. Call
|
automatically via [showtext] when the package is attached. Call
|
||||||
[civilytics_load_fonts()] to reload them if needed.
|
[civilytics_load_fonts()] to reload them if needed.
|
||||||
}
|
}
|
||||||
|
\section{Font size hierarchy}{
|
||||||
|
|
||||||
|
All text sizes are derived from `font_size` using relative scale factors.
|
||||||
|
At the default `font_size = 14`:
|
||||||
|
|
||||||
|
| Element | Scale factor | Default size |
|
||||||
|
|:--------|:-------------|:-------------|
|
||||||
|
| Plot title | `rel_large` (1.43x) | ~20 pt |
|
||||||
|
| Subtitle | 1.0x | 14 pt |
|
||||||
|
| Axis text (tick labels) | `rel_small` (0.86x) | ~12 pt |
|
||||||
|
| Axis titles | `rel_small` (0.86x) | ~12 pt |
|
||||||
|
| Legend text | `rel_small` (0.86x) | ~12 pt |
|
||||||
|
| Caption | `rel_tiny` (0.79x) | ~11 pt |
|
||||||
|
| Legend title | `rel_tiny` (0.79x) | ~11 pt |
|
||||||
|
| Strip text (facets) | `rel_small` (0.86x) | ~12 pt |
|
||||||
|
|
||||||
|
To uniformly scale all text, change `font_size`. To adjust only the title
|
||||||
|
prominence, change `rel_large`. When using [civilytics_logo()] to add a
|
||||||
|
logo below the plot, pass `font_scale` to compensate for viewport
|
||||||
|
shrinkage.
|
||||||
|
}
|
||||||
|
|
||||||
\examples{
|
\examples{
|
||||||
\dontrun{
|
\dontrun{
|
||||||
library(ggplot2)
|
library(ggplot2)
|
||||||
@@ -97,5 +120,10 @@ ggplot(mpg, aes(displ, hwy, colour = class)) +
|
|||||||
ggplot(mpg, aes(displ, hwy)) +
|
ggplot(mpg, aes(displ, hwy)) +
|
||||||
geom_point() +
|
geom_point() +
|
||||||
theme_civilytics(paper_bg = FALSE)
|
theme_civilytics(paper_bg = FALSE)
|
||||||
|
|
||||||
|
# Larger text for poster or display
|
||||||
|
ggplot(mpg, aes(displ, hwy)) +
|
||||||
|
geom_point() +
|
||||||
|
theme_civilytics(font_size = 18)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ theme_civilytics_dark(
|
|||||||
line_size = 0.5,
|
line_size = 0.5,
|
||||||
rel_small = 12/14,
|
rel_small = 12/14,
|
||||||
rel_tiny = 11/14,
|
rel_tiny = 11/14,
|
||||||
rel_large = 16/14,
|
rel_large = 20/14,
|
||||||
ink = unname(civilytics_colors["paper"]),
|
ink = unname(civilytics_colors["paper"]),
|
||||||
paper = unname(civilytics_colors["navy_700"]),
|
paper = unname(civilytics_colors["navy_700"]),
|
||||||
accent = unname(civilytics_colors["ember_400"]),
|
accent = unname(civilytics_colors["ember_400"]),
|
||||||
@@ -38,7 +38,8 @@ Default `"Libre Franklin"` (loaded via showtext).}
|
|||||||
Default `11/14`.}
|
Default `11/14`.}
|
||||||
|
|
||||||
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
|
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
|
||||||
`font_size`. Default `16/14`.}
|
`font_size`. Default `20/14` (~1.43x), matching the Civilytics editorial
|
||||||
|
design system.}
|
||||||
|
|
||||||
\item{ink}{Character. Hex code for foreground/text color. Defaults to
|
\item{ink}{Character. Hex code for foreground/text color. Defaults to
|
||||||
[civilytics_colors]`["ink"]` (`#0E1A2B`).}
|
[civilytics_colors]`["ink"]` (`#0E1A2B`).}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ theme_civilytics_slide(
|
|||||||
line_size = 0.5,
|
line_size = 0.5,
|
||||||
rel_small = 12/14,
|
rel_small = 12/14,
|
||||||
rel_tiny = 11/14,
|
rel_tiny = 11/14,
|
||||||
rel_large = 16/14,
|
rel_large = 20/14,
|
||||||
ink = unname(civilytics_colors["ink"]),
|
ink = unname(civilytics_colors["ink"]),
|
||||||
paper = unname(civilytics_colors["paper"]),
|
paper = unname(civilytics_colors["paper"]),
|
||||||
accent = unname(civilytics_colors["ember_600"]),
|
accent = unname(civilytics_colors["ember_600"]),
|
||||||
@@ -38,7 +38,8 @@ Default `"Libre Franklin"` (loaded via showtext).}
|
|||||||
Default `11/14`.}
|
Default `11/14`.}
|
||||||
|
|
||||||
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
|
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
|
||||||
`font_size`. Default `16/14`.}
|
`font_size`. Default `20/14` (~1.43x), matching the Civilytics editorial
|
||||||
|
design system.}
|
||||||
|
|
||||||
\item{ink}{Character. Hex code for foreground/text color. Defaults to
|
\item{ink}{Character. Hex code for foreground/text color. Defaults to
|
||||||
[civilytics_colors]`["ink"]` (`#0E1A2B`).}
|
[civilytics_colors]`["ink"]` (`#0E1A2B`).}
|
||||||
|
|||||||