The goal of paleval is to help you evaluate the effectiveness of color palettes and color maps. It builds from the colorspace package, used to design color maps, and the farver package, used to evaluate the perceptual difference between two colors.

This will have to go into a design-document eventually, but for now, I’ll “puke” this here.

For the purpose of this package, following colorRamp and ggplot2 usage, we define some classes:

  • pev_fcont: A function that describes a continuous palette. When called with a numeric vector with values between 0 and 1, it returns a vector of the corresponding (hex-code) values.

  • pev_fdisc: A function that describes a discrete palette. When called with a single integer argument (the number of levels in the scale), it returns a vector of the (hex-code) value for the entire scale. There are two types of discrete-palette functions:

    • pev_bounded: Indicates that there is an upper-bound on the number of colors it can provide, e.g. Tableau 10. You would not think to interpolate between these colors.

    • pev_unbounded: Indicates that there is no upper-bound on the number of colors it can provide, e.g. "Pastel". You might think to interpolate between these colors.

These follow the palette argument for ggplot2::continuous_scale() and ggplot2::discrete_scale(), as well as graphics::colorRamp() and graphics::colorRampPalette(), respectively.

I’m suspect I’m doing things in a way that the authors of colorspace, ggplot2, farver, and graphics might prefer not to consider while eating. As much as anything, this package is an attempt to reationalize and harmonize all of these concepts to myself.

There are ways to create continuous-palette functions:

  • pev_fcont(): constructor
    • takes a vector (more than one) of hex-colors to be interpolated.
    • takes a (one) name of a colorspace palette.
    • takes a set of HCL parameters, following the colorspace framework.
    • takes a function.
    • takes a pev_fcont (no-op).
  • pev_fcont_cvd(): modifies the output of the palette function according to color-vision deficiency.
  • pev_fcont_diverging(): composes two continuous-palette functions to create (presumably) a diverging palette-function. It’s up to you to make sure the constituent palettes “meet in the middle”.
  • pev_fcont_rescale(): rescaling an existing continuous-palette function. It may make sense to “zoom-in”, but “zooming-out” could get you into trouble.
  • pev_fcont_reverse(): reverses the sense of the palette function.

There are ways to create discrete-palette functions:

  • pev_fdisc(): constructor

    • takes a vector of hex-colors, returns a bounded function.
    • takes a pev_fcont, given a discretization method (e.g. "panel" or "post"), returns an unbounded function.
    • takes a pev_fdisc (no-op).
  • pev_fdisc_cvd(): modifies the output of the palette function according to color-vision deficiency.

  • pev_fdisc_reverse(): reverses the sense of the palette function.

  • print(): prints a representation of the palette function.

Other functions:

Here’s a reference on delta E - can we find something more definitive?

Installation

You can install the development version of paleval from GitHub with:

Example

pev_data_hcl("Dynamic", n = 12) %>% pev_gg_hcl_bloom()

pev_gg_hcl_plane(data_hcl, data_hcl_ref)

pev_gg_hcl_spectrum(data_hcl, data_hcl_ref)

Code of Conduct

Please note that the ‘paleval’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.