MyNixOS website logo
Description

National Road Safety Observatory (ONSV) Style for 'ggplot2' Graphics.

Helps to create 'ggplot2' charts in the style used by the National Road Safety Observatory (ONSV). The package includes functions to customize 'ggplot2' objects with new theme and colors.

onsvplot

R-CMD-check

The goal of onsvplot is to provide ggplot theme and color elements to help create graphics in the style of the National Observatory for Road Safety.

Overview

This package provides two main functions and a palette of colors:

  • theme_onsv(): Apply the ONSV theme to a ggplot object;
  • scale_discrete_onsv(): Apply the ONSV color palette to a ggplot object;
  • onsv_palette: A data object which provides the full palette of colors, including its hex codes.

Installation

You can install the development version of onsvplot like so:

remotes::install_github("pabsantos/onsvplot")

Or the CRAN version:

# install.packages("onsvplot")

Example

This is a basic example which shows you how to apply the functions included in this package. First, a basic ggplot graphics:

library(onsvplot)
library(ggplot2)

plot1 <- ggplot(data = iris, aes(
  x = Sepal.Length, y = Sepal.Width, color = Species
)) +
  geom_point()

plot1

Then, apply theme_onsv() to change the theme of the plot and scale_discrete_onsv() to change the colors:

theme_set(theme_onsv())

plot1 + scale_discrete_onsv()

If only one color is necessary in the plot, it is possible to use one of the colors included in the onsv_palette object;

str(onsv_palette)
#> List of 12
#>  $ blue       : chr "#00496d"
#>  $ yellow     : chr "#f7951d"
#>  $ red        : chr "#d51f29"
#>  $ green      : chr "#1fa149"
#>  $ pink       : chr "#ec0d6b"
#>  $ orange     : chr "#f05f22"
#>  $ lightblue  : chr "#99B6C5"
#>  $ lightyellow: chr "#FCD5A5"
#>  $ lightred   : chr "#EEA5A9"
#>  $ lightgreen : chr "#A5D9B6"
#>  $ lightpink  : chr "#F79EC4"
#>  $ lightorange: chr "#F9BFA7"

applying directly to the color or fill of the geom:

ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) +
  geom_point(color = onsv_palette$yellow)

Citation

If you want to cite this package, you can cite as:

#> To cite package 'onsvplot' in publications use:
#> 
#>   Santos PAB (2023). _onsvplot: National Road Safety Observatory (ONSV)
#>   Style for 'ggplot2' Graphics_. R package version 0.3.2,
#>   <https://github.com/pabsantos/onsvplot/>.
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Manual{,
#>     title = {onsvplot: National Road Safety Observatory (ONSV) Style for 'ggplot2' Graphics},
#>     author = {Pedro Augusto Borges Santos},
#>     year = {2023},
#>     note = {R package version 0.3.2},
#>     url = {https://github.com/pabsantos/onsvplot/},
#>   }
Metadata

Version

0.3.2

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