theme_nhsbsa_gg | R Documentation |
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
theme_nhsbsa_gg(plot, family = "sans")
family |
String font family to use (this must be installed and loaded). Default value is "sans" (e.g. "TT Arial"). |
ggplot
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.