This function generates an HCL palette for visualizing a small set of distributions (i.e., eight or fewer) that are not ordered in a linear or cyclical sequence (e.g., a set of utilization distributions describing space use by five separate individuals in the same population or a set of four species distributions that depend on similar food resources).

palette_set(x, custom_hues)

Arguments

x

RasterStack or integer describing the number of layers for which colors need to be generated.

custom_hues

vector of integers between -360 and 360 representing hues in the color wheel. For further details, consult the documentation for colorspace::rainbow_hcl. The length of the vector must equal the number of layers described by x. Hues are assigned to layers in order.

Value

A data frame with three columns:

  • layer_id: integer identifying the layer containing the maximum intensity value; mapped to hue.

  • specificity: the degree to which intensity values are unevenly distributed across layers; mapped to chroma.

  • color: the hexadecimal color associated with the given layer and specificity values.

See also

palette_timecycle for cyclical sequences of distributions and palette_timeline for linear sequences of distributions.

Other palette: palette_timecycle(), palette_timeline()

Examples

# load elephant data
data(elephant_ud)

# generate hcl color palette
pal <- palette_set(elephant_ud)
head(pal)
#>   specificity layer_id   color
#> 1           0        1 #6A6A6A
#> 2           0        2 #6A6A6A
#> 3           1        1 #696B6B
#> 4           1        2 #6C6A6A
#> 5           2        1 #686B6B
#> 6           2        2 #6D6A6A

# visualize the palette in HCL space with colorspace::hclplot
library(colorspace)
#> 
#> Attaching package: ‘colorspace’
#> The following object is masked from ‘package:raster’:
#> 
#>     RGB
hclplot(pal[pal$specificity == 100, ]$color)
#> Warning: the standard deviation is zero