Skip to contents

This function returns a color value for each row of the 2-column dataset supplied, based on a 2D color palette defined by a center color and a series of peripheral colors.

Usage

colorwheel2d(
  data,
  colors = c("black", "yellow", "green", "cyan", "blue", "magenta", "red"),
  origin = NULL,
  xyratio = NULL,
  kernel = NULL
)

Arguments

data

Matrix or data frame with 2 numeric columns; they will map to x and y.

colors

Vector of colors to interpolate: center followed by periphery counterclockwise from 3 o'clock.

origin

Coordindates of color wheel center.

xyratio

Scalar representing how to map the elliptical color wheel in the data space (the default 1 a circular mapping that weights the two dimensions equally).

kernel

Optional function describing the shape of radial color gradients (default is a linear mapping corresponding to a triangular kernel); this function should take a vector of distances to the center as its sole input and return a positive number.

Value

Character vector of colors.

Examples

plot(iris, 
      col = colorwheel2d(iris[, c("Sepal.Length", "Sepal.Width")]), 
      pch = 19, cex = 2)

      
plot(iris, 
      col = colorwheel2d(
                  iris[, c("Sepal.Length", "Sepal.Width")],
                  origin = c(5.5, 2.5),
                  kernel = function(x) x ^ .5), 
      pch = 19, cex = 2)