Skip to contents

An R package with colour palettes and a ggplot2 theme that are consistent with The University of Warwick’s branding, especially its colours and typography.

The palettes are built using the palettes package. The ggplot2 theme is heavily inspired by the work of Cara Thompson, particularly this talk on applying a unifying aesthetic to your plots.

Installation

You can install the development version of warwickplots from GitHub with:

# install.packages("remotes")
remotes::install_github("Warwick-Stats-Resources/warwickplots")

Palettes

The package offers six colour palettes: one discrete, two divergent and three sequential:

library(warwickplots)
#> Loading required package: palettes
plot(warwick_palettes)

For further details on using the palettes, please see the get started with warwickplots vignette and the documentation for the palettes package.

theme_warwick()

Below is a plot that uses the warwick_palettes::primary palette and theme_warwick().

library(ggplot2)
library(palmerpenguins)
ggplot(penguins, aes(flipper_length_mm, body_mass_g, group = species)) +
  geom_point(aes(colour = species, shape = species), alpha = 0.8, size = 2) +
  scale_color_palette_d(warwick_palettes$primary) +
  labs(title = "Penguin Size, Palmer Station LTER",
       subtitle = "Flipper length and body mass for **<span style = 'color:#3C1053;'>Adelie</span>**, **<span style = 'color:#6DCDB8;'>Chinstrap</span>** and **<span style = 'color:#CB333B;'>Gentoo</span>** Penguins. This is based on data made available in the **palmerpenguins** R package.",
       caption = "Visualization: Ella Kaye, Data: Gorman, Williams & Fraser (2014) DOI: 10.1371/journal.pone.009008",
       x = "flipper length (mm)",
       y = "body mass (g)") +
  theme_warwick() +
  theme(legend.position = 'none')

theme_warwick() is an extension of ggplot2::theme_minimal(), offering the following in addition:

  • Text hierarchy, with different sizes and colours
  • Spacing, giving the text room to breathe
  • Uses ggtext::element_textbox_simple() for the plot title and subtitle, to enable use of markdown and CSS styling, and text-wrapping if the title/subtitle is long
  • Places the legend above the plot
  • Uses Lato or Avenir Next font (for online or print use respectively), if your system is set up for it

Note that any theme_warwick() defaults can be overridden with a subsequent call to theme().

For further details, including how to ensure your system is set up to use custom fonts, see the get started warwickplots vignette. For further examples, including how to override theme_warwick(), see the using warwickplots with ggplot2 vignette.