Package 'paletteNMR'

Title: Helper functions for using the NMR color palettes
Description: paletteNMR provides functions to access and browse the set of palettes available for use in publications at NMR. The main palette set is NMR's internal set, but the package also contains palettes for use with other clients' projects, and can be expanded to include other palettes as needed. Call 'vignette("intro", "paletteNMR")' to see more information.
Authors: Jerrad Pierce [aut], Julian Ricardo [prg, cre]
Maintainer: Julian Ricardo <[email protected]>
License: GPL-3 + file LICENSE
Version: 1.1.6
Built: 2024-10-18 03:15:00 UTC
Source: https://gitlab.com/NMRgroup/paletteNMR

Help Index


Check if an object has names

Description

Check if an object has names

Check if an object has names

Usage

checkHasNames(x)

## Default S3 method:
checkHasNames(x)

Arguments

x

An object to check for names.

Value

Confirmation that object has valid names.


Check an object for valid hex colors

Description

Check an object for valid hex colors

Check an object for valid hex colors

Check a list for valid hex colors

Check a vector for valid hex colors

Check a data.frame for valid hex colors

Usage

checkValidHex(x)

## Default S3 method:
checkValidHex(x)

## S3 method for class 'list'
checkValidHex(x)

## S3 method for class 'vector'
checkValidHex(x)

## S3 method for class 'data.frame'
checkValidHex(x)

Arguments

x

An object containing colors (as strings)

Value

Confirmation that object contains only valid colors, or some explanation of errors if it contains invalid ones.


Draw a palette using 'nmr_colors'

Description

Draw a palette using 'nmr_colors'

Usage

draw_palette(
  scale = "categorical",
  pal = "quad",
  set = "O",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  ncols = 1
)

Arguments

scale

String to select colors for categorical or numerical scales

pal

String to select palette type (e.g. for categorical, pairs or quads)

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

ncols

A number of columns to display in the drawn palette

Value

A grid of color swatches

Examples

draw_palette(scale = "numerical", pal = "nondiverg", set = "BT6", index = 1:4, ncols = 2)

draw_palette(scale = "categorical", pal = "quad", set = "O")

Helper function to select names used in calling 'nmr_colors'

Description

Helper function to select names used in calling 'nmr_colors'

Usage

get_pal_args(
  arg_list,
  colname_str = "(^(scale|pal|set|index|contrast|discrete|interpolate|reverse))"
)

Arguments

arg_list

A list of arguments used to call the function calling 'get_pal_args'

colname_str

A string selecting arguments by name (regex allowed)

Value

A subset of supplied argument names


Slim NEEA Market Research & Evaluation color palette, from 2017

Description

A single categorical palette we last used for NEEA in 2020

Usage

neeaPalettes_2017

Format

A list of 1 dataframe containing separate color palettes


Slim Nexant color palette

Description

A single categorical palette we last used for Nexant in PY2019

Usage

nexantPalettes_2017

Format

A list of 1 dataframe containing separate color palettes


Helper function to access palette colors

Description

Some palettes are loaded in with contrasting colors for use with text. Note: accepts regex statements in arguments.

Usage

nmr_colors(
  scale = c("categorical", "numerical"),
  pal,
  set,
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020
)

Arguments

scale

String to select colors for categorical or numerical scales

pal

String to select palette type (e.g. for categorical, pairs or quads)

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

Value

A named vector containing colors

Examples

nmr_colors(scale = "categorical", pal = "lines", set = "All")
nmr_colors(scale = "categorical", pal = "quad", set = "O")

Generate a palette function

Description

Generate a palette function

Usage

nmr_pal(
  scale = "Categorical",
  pal = "quad",
  set = "C",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

Arguments

scale

String to select colors for categorical or numerical scales

pal

String to select palette type (e.g. for categorical, pairs or quads)

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

interpolate

A boolean toggling whether to interpolate colors

reverse

A boolean toggling whether to reverse the palette

...

Additional arguents to pass to 'colorRampPalette'

Value

A (sub)set of colors from an NMR palette, or a set interpolated from one


NMR color swatches, 2020

Description

A dataframe of colors, used to create NMR palettes, along with some extras

Usage

nmrColors_2020

Format

A dataframe of color IDs and hex codes


Full NMR color palette, 08/18/17

Description

A list of color palettes, divided by category into "Main", "Numerical", "Categorical", and "Extras." Within some categories, there are further subdivisions into Ordinal / Divergent, Time-series / Map, and further lettered subdivisions.

Usage

nmrPalettes_2017

Format

A list of 10 dataframes, each containing separate color palettes


NMR palettes, 2020

Description

A list of color palettes broken up by type: categorical, diverging, sequential, maps. Some palettes have sets with different base colors

Usage

nmrPalettes_2020

Format

A list of 10 dataframes, each containing separate color palettes


Generate a categorical color scale with NMR colors

Description

Generate a categorical color scale with NMR colors

Generate a colour scale for nmr colors

Usage

scale_nmr_color_categorical(
  pal = "All",
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

scale_nmr_colour_categorical(
  pal = "All",
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

Arguments

pal

String to select palette type (e.g. for categorical, pairs or quads)

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

discrete

A boolean toggling whether the aesthetic is discrete

interpolate

A boolean toggling whether to interpolate colors

reverse

A boolean toggling whether to reverse the palette

...

Additional arguents to pass to 'colorRampPalette'

Value

A color scale for use in ggplot2 graphics.

See Also

scale_nmr_color_diverging, scale_nmr_color_sequential, scale_nmr_color_orthogonal


Generate a diverging color scale with NMR colors

Description

Generate a diverging color scale with NMR colors

Generate a colour scale for nmr colors

Usage

scale_nmr_color_diverging(
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

scale_nmr_colour_diverging(
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

Arguments

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

discrete

A boolean toggling whether the aesthetic is discrete

interpolate

A boolean toggling whether to interpolate colors

reverse

A boolean toggling whether to reverse the palette

...

Additional arguents to pass to 'colorRampPalette'

Value

A color scale for use in ggplot2 graphics.

See Also

scale_nmr_color_sequential, scale_nmr_color_orthogonal, scale_nmr_color_categorical


Generate a orthogonal color scale with NMR colors

Description

Generate a orthogonal color scale with NMR colors

Generate a colour scale for nmr colors

Usage

scale_nmr_color_orthogonal(
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

scale_nmr_colour_orthogonal(
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

Arguments

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

discrete

A boolean toggling whether the aesthetic is discrete

interpolate

A boolean toggling whether to interpolate colors

reverse

A boolean toggling whether to reverse the palette

...

Additional arguents to pass to 'colorRampPalette'

Value

A color scale for use in ggplot2 graphics.

See Also

scale_nmr_color_diverging, scale_nmr_color_sequential, scale_nmr_color_categorical


Generate a sequential color scale with NMR colors

Description

Generate a sequential color scale with NMR colors

Generate a colour scale for nmr colors

Usage

scale_nmr_color_sequential(
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

scale_nmr_colour_sequential(
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

Arguments

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

discrete

A boolean toggling whether the aesthetic is discrete

interpolate

A boolean toggling whether to interpolate colors

reverse

A boolean toggling whether to reverse the palette

...

Additional arguents to pass to 'colorRampPalette'

Value

A color scale for use in ggplot2 graphics.

See Also

scale_nmr_color_diverging, scale_nmr_color_orthogonal, scale_nmr_color_categorical


Generate a categorical fill scale with NMR colors

Description

Generate a categorical fill scale with NMR colors

Usage

scale_nmr_fill_categorical(
  pal = "All",
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

Arguments

pal

String to select palette type (e.g. for categorical, pairs or quads)

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

discrete

A boolean toggling whether the aesthetic is discrete

interpolate

A boolean toggling whether to interpolate colors

reverse

A boolean toggling whether to reverse the palette

...

Additional arguents to pass to 'colorRampPalette'

Value

A color scale for use in ggplot2 graphics.

See Also

scale_nmr_fill_diverging, scale_nmr_fill_sequential, scale_nmr_fill_orthogonal


Generate a diverging fill scale with NMR colors

Description

Generate a diverging fill scale with NMR colors

Usage

scale_nmr_fill_diverging(
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

Arguments

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

discrete

A boolean toggling whether the aesthetic is discrete

interpolate

A boolean toggling whether to interpolate colors

reverse

A boolean toggling whether to reverse the palette

...

Additional arguents to pass to 'colorRampPalette'

Value

A color scale for use in ggplot2 graphics.

See Also

scale_nmr_fill_sequential, scale_nmr_fill_orthogonal, scale_nmr_fill_categorical


Generate a orthogonal fill scale with NMR colors

Description

Generate a orthogonal fill scale with NMR colors

Usage

scale_nmr_fill_orthogonal(
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

Arguments

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

discrete

A boolean toggling whether the aesthetic is discrete

interpolate

A boolean toggling whether to interpolate colors

reverse

A boolean toggling whether to reverse the palette

...

Additional arguents to pass to 'colorRampPalette'

Value

A color scale for use in ggplot2 graphics.

See Also

scale_nmr_fill_diverging, scale_nmr_fill_sequential, scale_nmr_fill_categorical


Generate a sequential fill scale with NMR colors

Description

Generate a sequential fill scale with NMR colors

Usage

scale_nmr_fill_sequential(
  set = "",
  index = NULL,
  pal_df = paletteNMR::nmrPalettes_2020,
  discrete = TRUE,
  interpolate = FALSE,
  reverse = FALSE,
  ...
)

Arguments

set

String to select set of colors in palette (e.g. different variations or base colors)

index

A set of numerical values to subset palette

pal_df

List of dataframes containing color palettes, defaults to internal package data

discrete

A boolean toggling whether the aesthetic is discrete

interpolate

A boolean toggling whether to interpolate colors

reverse

A boolean toggling whether to reverse the palette

...

Additional arguents to pass to 'colorRampPalette'

Value

A color scale for use in ggplot2 graphics.

See Also

scale_nmr_fill_diverging, scale_nmr_fill_orthogonal, scale_nmr_fill_categorical


Theme with NMR color palette

Description

Theme with NMR color palette

Usage

theme_nmr(base_size = 11, base_family = "sans")

Arguments

base_size

Numerical to set font sizes

base_family

String to set font family

Value

A ggplot2 theme theme_minimal