Simple and flexible color scale.

colorScale(
  x,
  y,
  col,
  at = NULL,
  labels = NULL,
  horiz = TRUE,
  percx = NULL,
  percy = NULL,
  adj = 0,
  labels.cex = 1,
  title = "legend",
  title.cex = 1.2
)

Arguments

x

x-coordinates of the bottom-left corner of the legend.

y

y-coordinates of the bottom-left corner of the legend.

col

vector of colors.

at

vector of integers indicating colors to be labeled.

labels

labels.

horiz

a logical. Should the color scale be horizontal?

percx

size of the color scale along x axis.

percy

size of the color scale along y axis.

adj

adjust the position labels position. If adj = 0 then labels are at the bottom if horiz = TRUE and on the the left if horiz = FALSE. If adj = 1, labels are at the top if horiz = TRUE and on the the right if horiz = FALSE. So far if horiz = TRUE, title and labels are on opposite sides.

labels.cex

magnification to be used for labels.

title

legend title.

title.cex

magnification to be used for the title.

Examples

plot(c(0,10), c(0,10))
colorScale(5, 5, gpuPalette("cisl", 10), at = c(2, 4))