theme_ipr: IPR theme for ggplot2

View source: R/theme_ipr.R

theme_iprR Documentation

IPR theme for ggplot2

Description

Returns an IPR-style theme for adding to a ggplot2. See Details for font-specific instructions.

Usage

theme_ipr(
  grid = "both",
  richtext = F,
  axis_titles = F,
  scatter = F,
  base_size = 12,
  family = "Unit Pro",
  title_family = "Unit Slab Pro",
  side_margin = 5.5
)

Arguments

grid

character: which major gridlines to display. "x", "y" or "both". Defaults to "both".

richtext

whether to render markdown/HTML using the 'marquee' package. Defaults to FALSE.

axis_titles

whether to display axis titles. Defaults to FALSE.

scatter

If TRUE, will add panel background and inverse x and y gridlines. Defaults to FALSE.

base_size

base font size. Defaults to 12.

family

Font family to use throughout the theme. Defaults to "Unit Pro".

title_family

Font family to use in the title. Defaults to "Unit Slab Pro".

side_margin

Size of left and right margin in pts.

Details

In its default setting, it requires the Unit Pro and Unit Slab Pro fonts to be present. As these are OTF files, they are automatically loaded using the sysfonts package, assuming the files UnitPro[-Bold].otf and UnitSlabPro[-Bold].otf exist in the usual font locations.

The font is not rendered correctly in the RStudio graphics device, but works in RMarkdown notebooks and PDFs. To make it work with knitr, add 'fig.showtext=TRUE' to your chunk options or to your setup chunk using 'knitr::opts_knit$set(fig.showtext=TRUE)'. Call 'showtext_auto()' before calling your ggplot2 object.

Note that this only applies to HTML output. For Word output, a template is needed and for PDF output much fiddling with TeX is needed. Single PDF images are fine.

Value

A ggplot2 theme object, an object of class theme and gg.

Examples

# ADD_EXAMPLES_HERE

petrbouchal/ptrr documentation built on Oct. 10, 2024, 7:21 a.m.