theme_nhsbsa_gg: Theme an NHSBSA ggplot

View source: R/theme_nhsbsa.R

theme_nhsbsa_ggR Documentation

Theme an NHSBSA ggplot

Description

Theme an NHSBSA ggplot. We would like to take several steps to brand a standard ggplot to an NHSBSA looking chart. These include:

  • Make the font of any text "sans" or another family parameter.

  • Colour any text NHS Black

  • Colour background NHS White

  • Make the title and axis titles bold

  • Left align the subtitle

  • Move the legend to the top with no background or key background

  • Remove axis titles (but set them bold incase they are added later). Note that to add axis titles you must first add the element back in like this: ggplot2::theme(axis.title.x = ggplot2::element_text()) + ggplot2::xlab()

  • Colour axis lines NHS Mid Grey

  • Remove axis ticks

  • Remove all gridlines

  • Colour the background of the plot white

  • Colour background NHS White

  • For facets, bold and left align the titles and colour the panel background

Usage

theme_nhsbsa_gg(plot, family = "sans")

Arguments

family

String font family to use (this must be installed and loaded). Default value is "sans" (e.g. "TT Arial").

Value

ggplot

Examples

# Standard usage
ggplot2::ggplot(data = ggplot2::diamonds) +
  ggplot2::geom_bar(mapping = ggplot2::aes(x = cut)) +
  nhsbsaR::theme_nhsbsa_gg()

# Add an axis label
ggplot2::ggplot(data = ggplot2::diamonds) +
  ggplot2::geom_bar(mapping = ggplot2::aes(x = cut)) +
  nhsbsaR::theme_nhsbsa_gg() +
  ggplot2::theme(axis.title.x = ggplot2::element_text()) +
  ggplot2::xlab("Cut")

nhsbsa-data-analytics/nhsbsaR documentation built on Jan. 25, 2025, 8:54 a.m.