A white-background ggplot2 theme based on the Urban Institute style,
with gray horizontal grid lines and a clean, minimal aesthetic. Designed
to pair with viridis, inferno, grayscale, or solaris color palettes
(set via set_theme).
Usage
theme_t2m(
base_size = 12,
base_family = "sans",
base_line_size = 0.5,
base_rect_size = 0.5,
panel_spacing = 6,
network = NULL,
medium = c("screen", "print")
)Arguments
- base_size
Numeric. Base font size in points (default
12).- base_family
Character. Base font family (default
"sans").- base_line_size
Numeric. Base line size for theme elements (default
0.5).- base_rect_size
Numeric. Base rectangle border size for theme elements (default
0.5).- panel_spacing
Numeric. Spacing between facet panels in points (default
6).- network
Logical or
NULL(default). IfNULL, ggraph plots are auto-detected at plot-add time and network mode is applied automatically. PassTRUEto force network mode (no axes/grid) orFALSEto force standard mode regardless of plot type.- medium
Character. Output medium:
"screen"(default) for presentations and PDF viewing, or"print"for physical printing with heavier lines and darker text.
Value
When network = NULL (default), an object of class
"theme_text2map_autodetect" that resolves at + time.
When network is explicitly TRUE or FALSE, a
plain ggplot2 theme object.
Details
When added to a plot with +, theme_t2m() auto-detects
whether the plot is a ggraph network visualization and removes
axes and grid lines accordingly. Pass network = TRUE or
network = FALSE to override auto-detection.
Note
theme_t2m() is based on the Urban Institute theme (https://urban-institute.graphics/).
Examples
if (FALSE) { # \dontrun{
library(ggplot2)
# Basic usage -- auto-detects plot type
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
theme_t2m()
# Print-optimized with heavier lines
ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
geom_point(size = 3) +
theme_t2m(medium = "print")
} # }
