MyNixOS website logo
Description

RSS Palettes and Themes.

Defines colour palettes and themes for Royal Statistical Society (RSS) publications, including Significance magazine. Palettes and themes are supported in both base R and 'ggplot2' graphics, and are intended to be used by authors submitting to RSS publications.

R-CMD-check

{RSSthemes}

{RSSthemes} is an R package for styling graphics for RSS publications. This package accompanies the Best Practices for Data Visualisation guidance, published by the Royal Statistical Society, which can be found at royal-statistical-society.github.io/datavisguide.

This package, the data visualisation guidance site and its content are under development, and the authors welcome feedback and contributions.

Using the {RSSthemes} package

A brief overview of the package is given below. For a more in-depth discussion of this R package please see royal-statistical-society.github.io/datavisguide/docs/tools.html for the most up-to-date information.

You can install the package from CRAN using:

install.packages("RSSthemes")

You can install the development version from GitHub with:

remotes::install_github("nrennie/RSSthemes")

You can then load the package using:

library(RSSthemes)

Colour palettes

There are currently three palettes available in {RSSthemes}, although we hope to add more in the future.

Using palettes with {ggplot2}

Let’s set up a basic data set.

library(ggplot2)
plot_df <- data.frame(x = LETTERS[1:4],
                      y = 1:4)

Single colour charts

If all of the bars, lines, points, etc. should have the same colour, you can set either the fill or colour arguments to have one of the RSS colours. The options are: signif_red, signif_blue, signif_green, signif_orange, or signif_yellow.

ggplot(data = plot_df,
       mapping = aes(x = x, y = y)) +
  geom_col(fill = signif_yellow)

Qualitative palettes

For working with qualitative (discrete) data, the best palette to use is "signif_qual". This palette currently only contains four colours.

Discrete (fill) scale: scale_fill_rss_d()

ggplot(data = plot_df,
       mapping = aes(x = x, y = y, fill = x)) +
  geom_col() +
  scale_fill_rss_d(palette = "signif_qual")

Discrete (colour) scale: scale_colour_rss_d()

ggplot(data = plot_df,
       mapping = aes(x = x, y = y, colour = x)) +
  geom_point(size = 4) +
  scale_colour_rss_d(palette = "signif_qual")

Sequential palettes

For working with sequential (continuous) data, the best palette to use is "signif_seq".

Continuous (fill) scale: scale_fill_rss_c()

ggplot(data = plot_df,
       mapping = aes(x = x, y = y, fill = y)) +
  geom_col() +
  scale_fill_rss_c(palette = "signif_seq")

Continuous (colour) scale: scale_colour_rss_c()

ggplot(data = plot_df,
       mapping = aes(x = x, y = y, colour = y)) +
  geom_point(size = 4) +
  scale_colour_rss_c(palette = "signif_seq")

Diverging palettes

For working with diverging (continuous) data, the best palette to use is "signif_div".

Continuous (fill) scale: scale_fill_rss_c()

ggplot(data = plot_df,
       mapping = aes(x = x, y = y, fill = y)) +
  geom_col() +
  scale_fill_rss_c(palette = "signif_div")

If you want to centre the diverging scale around a different value, you can alternatively pass the pre-defined colours into scale_fill_gradient2() from {ggplot2}:

ggplot(data = plot_df,
       mapping = aes(x = x, y = y, fill = y)) +
  geom_col() +
  scale_fill_gradient2(low = signif_red, high = signif_blue, midpoint = 2)

Using palettes with base R

If all of the bars, lines, points, etc. should have the same colour, you can set col arguments to have one of the RSS colours. The options are: signif_red, signif_blue, signif_green, signif_orange, or signif_yellow.

barplot(table(mtcars$gear), col = signif_blue)

You can use the set_rss_palette() function to change the default colours used in base R plotting:

set_rss_palette("signif_qual")
plot(1:4, 1:4, col=1:4, pch=19, cex=3, xlab="", ylab="")

Run palette("default") to reset to original base R colours.

Theme functions

Theme functions style the non-data elements of plots, e.g. fonts, text colour, or background colour.

Using themes with {ggplot2}

Apply styling to plots made with {ggplot2} using the theme_significance() function:

ggplot(data = plot_df,
       mapping = aes(x = x, y = y, fill = x)) +
  geom_col() +
  labs(title = "My Significance Plot",
       subtitle = "Some longer sentence explaining what is happening in the chart.",
       caption = "Source: name of data source") +
  scale_fill_rss_d(palette = "signif_qual") +
  theme_significance()

Using themes with base R

Apply styling to plots made with base R using the set_signif_par() function. We also recommend adding reference lines using the abline() function:

set_signif_par()
plot(1:4, 1:4, col=1:4, pch=19, cex=3, xlab="", ylab="",
     main = "My Significance Plot",
     sub = "Source: data source")
abline(h=1:4, v=1:4, col = "lightgrey")

Contributor guidelines

To make a suggestion or ask a question

Please open up a discussion in the repository's Discussions section.

If you spot a bug or an error

Please either:

  1. Raise an issue in the repository's Issues section, or
  2. Fork this repository, edit the relevant file(s), and make a pull request against the main branch of this repository.

If you want to add a new feature or section to the R package:

  1. Raise an issue in the repository's Issues section, tag it as an 'enhancement' and describe your proposed contribution.
  2. Fork this repository and create a new branch named, e.g., my-new-feature-or-section.
  3. Add content, code and files to your branch.
  4. Make a pull request against the main branch of this repository.

Proposals for new features will be reviewed by the lead author team ("lead authors"):

  • Andreas Krause

  • Nicola Rennie

  • Brian Tarran

Lead authors may offer feedback or suggestions to contributors before agreeing to merge pull requests. Lead authors reserve the right to refuse to merge pull requests, and the decision of the lead authors is final.

Use of, and all contributions to, our website and repository are governed by our Code of Conduct.

This package is licensed under a Creative Commons Attribution 4.0 (CC BY 4.0) International licence, meaning it can be used and adapted for any purpose, provided attribution is given to the original authors. By contributing to this guide, contributors agree to licence their work under the same terms.

This package stores and loads Source Sans Pro fonts for use in the theme functions. Source Sans Pro font was developed by Paul D. Hunt, and more information can be found at fonts.adobe.com/fonts/source-sans. These fonts have the following copyright: Copyright 2010, 2012, 2014 Adobe Systems Incorporated https://www.adobe.com/, with Reserved Font Name ‘Source’. The fonts are licensed under the SIL Open Font License, Version 1.1. See: http://scripts.sil.org/OFL.

Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows