profinit_pal {profiplots}R Documentation

Profinit color palettes

Description

Returns function that interpolates (if exact=FALSE) chosen Profinit color palette. That is, the resulting function is able to give you desired number of colors (hexes) within given Profinit color palette.

Usage

profinit_pal(pal_name = "blue-red", reverse = FALSE, exact = NULL, ...)

Arguments

pal_name

Character name of chosen Profinit palette. See profinit_pal.pals() for available palettes.

reverse

Boolean indicating whether the palette should be reversed

exact

Indicates whether the color scale is supposed to be followed exactly. Be ware you may run out of colors. Defaults to TRUE for discrete palette names, FALSE otherwise.

...

Additional arguments to pass to grDevices::colorRampPalette()

Details

See the examples for more details about its usecase.

Value

A function providing desired number of colors (hex codes) from the specified palette.

Examples

# Example 1 - get colors from the 'discrete' Profinit palette
discrete_cols <- profinit_pal("discrete")
discrete_cols(3)
scales::show_col(discrete_cols(3))

# .. The number of colors is limited in this palette. Once you reach the
# limit, Profinit's grey is used to fill the missings:
scales::show_col(discrete_cols(10))

# .. You can bypass this via either enabling the interpolation (defaults
# to `FALSE` for `discrete`-like color palettes and `TRUE` for other palettes)
# or try your luck with full set of Profinit colors.
discrete_cols_int <- profinit_pal("discrete", exact = FALSE)
scales::show_col(discrete_cols_int(10))


# Example 2 - get colors from other Profinit palette
profinit_reds_cols <- profinit_pal("reds")
profinit_reds_cols(3)
scales::show_col(profinit_reds_cols(3))
# Again, we can interpolate
profinit_reds_cols(15)
scales::show_col(profinit_reds_cols(15))

# Example 3 - using palette in baseR plots
plot(mtcars$mpg, mtcars$qsec, col=profinit_pal("discrete")(5), pch=16)


[Package profiplots version 0.2.3 Index]