https://github.com/nhs-south-central-and-west/scwplot
R package for creating consistent SCW-style ggplot figures.
https://github.com/nhs-south-central-and-west/scwplot
data-visualisation ggplot r rstats
Last synced: 11 months ago
JSON representation
R package for creating consistent SCW-style ggplot figures.
- Host: GitHub
- URL: https://github.com/nhs-south-central-and-west/scwplot
- Owner: NHS-South-Central-and-West
- License: other
- Created: 2023-01-20T17:36:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-04T00:28:46.000Z (almost 3 years ago)
- Last Synced: 2025-06-13T14:07:45.915Z (about 1 year ago)
- Topics: data-visualisation, ggplot, r, rstats
- Language: R
- Homepage: https://nhs-south-central-and-west.github.io/scwplot/
- Size: 3.24 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r setup, include = FALSE}
#| label: setup
#| include: false
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[](https://github.com/NHS-South-Central-and-West/scwplot/actions/workflows/check-standard.yaml)
[](https://codecov.io/gh/NHS-South-Central-and-West/scwplot)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
The scwplot package provides functions for applying consistent SCW-branded aesthetics to ggplot visualisations in R, as well as additional functionality that produces clean plots and makes plotting in R easier.
## Installation
scwplot is not available on CRAN. In order to install the package, you must do so directly from this GitHub repository with {devtools}, using the code below:
```{r}
#| label: install-scwplot
#| eval: false
# install.packages("pak")
pak::pak("NHS-South-Central-and-West/scwplot")
```
If you haven't already installed devtools, you will also have to run the first line of code in the code chunk.
## Usage
The primary purpose of scwplot is to extend the functionality of ggplot to create consistent SCW-style figures, so usage builds on top of basic [ggplot2](https://ggplot2.tidyverse.org/) functionality.
A simple example of the scwplot usage:
```{r}
#| label: scwplot-basics
#| fig.width: 12
#| fig.height: 8
#| dpi: 300
library(ggplot2)
library(scwplot)
ggplot(mpg, aes(displ, hwy, fill = as.factor(cyl))) +
geom_jitter(
shape = 21, size = 6, stroke = 1,
alpha = .8, width = .5, height = 2.5
) +
labs(
title = "Example {scwplot} Usage with MPG Dataset",
subtitle = glue::glue(
"Plotting the Effect of Engine Displacement on ",
"Highway Miles Per Gallon, Split by Cylinders"
),
caption = "Source: EPA (https://fueleconomy.gov)",
x = "Engine Displacement (in Litres)", y = "Miles per Gallon"
) +
scale_fill_qualitative(palette = "scw") +
theme_scw()
```
The package includes the following functionality:
- Themes - functions for controlling the display of plot theme elements.
- Colour - functions for incorporating the use of colour to display data.
- Images - functions for adding images (i.e., brand images and logos) to plots.
- Format - functions for applying final formatting to a plot and saving it to file.
## Acknowledgements
This package takes a lot of inspiration from the NHS-R community's [NHSRtheme](https://github.com/nhs-r-community/NHSRtheme) package and BBC's [bbplot](https://github.com/bbc/bbplot) package. The code, the structure of the repository, and the approach taken to achieve the package's goals has been influenced by [ggplot2](https://ggplot2.tidyverse.org/) and [ggsci](https://nanx.me/ggsci/).
