/ggdfe

Primary LanguageROtherNOASSERTION

R-CMD-check

ggdfe

This package seeks to create an easy theme to add to any ggplot to keep it in line with DfE brand guidelines. Simply transforms existing ggplots into the house style of the Department for Education.

Colours

There are two functions that work to add in colour scales: scale_fill_dfe() and scale_colour_dfe(). These replace the usual scale_colour_*() and scale_fill_*() functions to change colours on ggplot.

These are the base colours

There are also palettes, passed to the ‘palettes’ argument. These are for selecting a suitable subset of the colours above, depending on if you need a discrete, continuous or diverging palette.

  • main - Blue red turquoise (discrete, 3 colours)
  • warm - Red to purple (continuous)
  • cool - Blue to lime (continuous)
  • full - all colours in the brand (discrete, 7 colours)
  • likert - red to blue, grey midpoint (diverging)
  • likert2 - green to purple, white midpoint (diverging)
  • likert3 - red to blue, white midpoint (diverging)
  • heat - white to red (continuous)
  • heat2 - white to pink (continuous)
  • cold - white to blue (continuous)
  • cold2 - white to turqouise (continuous)
  • pale - paler palettes for big blocks of colour (bar charts or treemaps)

Examples of usage would be:

Light theme

ggplot2::ggplot(data = iris)+
  ggplot2::aes(x=Sepal.Length, colour = Species)+
  ggplot2::geom_density(linewidth = 1.5)+
  scale_colour_dfe(palette = "main")+
  labs(title = "Default title is in dark blue",
       subtitle = "Default subtitle and copy text are dark grey",
       caption = "Using theme_dfe_light()")+
  theme_dfe_light()

Dark theme

ggplot2::ggplot(data = iris)+
  ggplot2::aes(x=Sepal.Length, colour = Species)+
  ggplot2::geom_density(linewidth = 1.5)+
  scale_colour_dfe(palette = "likert")+
  labs(title = "Dark title is pale blue",
       subtitle = "Dark subtitle and copy text are pale grey",
       caption = "Using theme_dfe_dark()")+
  theme_dfe_dark()

For clearer plot boundaries, there is also theme_nimbus().

plot <- ggplot(ggplot2::diamonds, aes(carat, price)) + geom_point() +
  labs(title = "Theme_nimbus",
       subtitle = "",
       caption = "theme_nimbus()")

plot + theme_nimbus()