A discrete-palette function takes an integers, from 1 to the maximum size of the palette, and returns a vector of character hex-codes. You con use a discrete-palette function to build a custom ggplot2 scale, using ggplot2::discrete_scale().

pev_fdisc(.fdisc, ...)

# S3 method for default
pev_fdisc(.fdisc, ...)

# S3 method for character
pev_fdisc(.fdisc, ...)

# S3 method for pev_fcont
pev_fdisc(.fdisc, method = c("post", "panel"), ...)

# S3 method for pev_fdisc
pev_fdisc(.fdisc, ...)

Arguments

.fdisc

object that can be coerced to pev_fdisc, when called with an integer, returns the corresponding (hex-code) values.

...

other arguments (not used).

method

character, describes how the domain of the continuous palette is to be discretized, can be "post" or "panel" (using a fencing analogy).

Value

function with S3 class pev_disc, when called with a numeric vector with values between 0 and 1, returns the corresponding (hex-code) values.

Details

These functions help you build, modify, and compose discrete-palette functions.

A discrete-palette function can be bounded or unbounded. A bounded function has a maxiumum number of possible colors, and is created from a series of hex-colors, for example, Tableau 10. An unbounded function is created from a continuous-palette function, thus has no maximum number of possible colors.

A discrete-palette function can be constructed using pev_fdisc(); it takes an argument .fdisc, which can be one of:

character

A series of hex-codes, returns a bounded discrete-palette function.

pev_fcont

A continuous-palette function, to be discretized according to method ("post" or "panel"). This returns an unbounded discrete-palette function.

pev_fdisc

If you provide a pev_fdisc, this is a no-op.

The print method for a pev_disc function generates a plot of the palette.

The other functions that return continuous-palette functions are:

pev_fdisc_cvd()

Modify output to simulate color-vision deficiency.

pev_fdisc_reverse()

Reverse palette-function.

Examples

# Use a colorspace palette pev_fdisc(pev_fcont("Blues 2"), n = 11, method = "post")