Learn R Programming

DImodelsVis (version 1.0.1)

get_colours: Return colour-blind friendly colours

Description

Utility function to return either a distinct colour-blind friendly colour for each variable or if a functional grouping is specified, then shades of the same colour for variables within a functional group

Usage

get_colours(vars, FG = NULL)

Value

A named vector containing the hex codes of colours

Arguments

vars

Either a numeric value `n` to get n colours, or a character vector of values where each value will be mapped to a colour.

FG

A character vector describing the functional grouping to which each variable belongs. Variables within the same group will have different shades of the same colour.

Examples

Run this code
## Get n colours
get_colours(vars = 4)

# Get a color-map for each value specified in vars
get_colours(vars = c("p1", "p2", "p3", "p4"))

# Group values of vars using FG. Variables in the same group
# will have same shades of a colour
get_colours(vars = 4, FG = c("G1", "G1", "G2", "G2"))

Run the code above in your browser using DataLab