| splot.color | R Documentation | 
Get a prespecified set of 9 colors, or a set of graded or random, potentially grouped colors.
splot.color(x = NULL, by = NULL, seed = "pastel", brightness = 0,
  luminance = 0, opacity = 1, extend = 0.7, lighten = FALSE,
  shuffle = FALSE, flat = TRUE, method = "scale", grade = FALSE,
  decreasing = FALSE, nas = "#000000")
x | 
 dictates the number and shade of colors. If a single value, returns that many samples of the
first   | 
by | 
 a vector to group   | 
seed | 
 a vector of color names or codes to adjust from, lining up with levels of   | 
brightness | 
 adjusts the RGB values of the seed color, usually between -1 and 1.  | 
luminance | 
 adjusts the white levels of the seed color, usually between -1 and 1.  | 
opacity | 
 sets the opacity of the seed color, between 0 and 1.  | 
extend | 
 if   | 
lighten | 
 logical; if   | 
shuffle | 
 logical; if   | 
flat | 
 logical; if   | 
method | 
 a character setting the sampling method: If   | 
grade | 
 logical; if   | 
decreasing | 
 logical; if   | 
nas | 
 value to replace missing values with.  | 
If x and by are not specified (or are characters with a length of 1, in which case they
are treated as seed), only the seed palette is returned.
To expand on a palette, seed colors are assigned to groups, and variants of each seed are assigned to values or levels within groups, or randomly or as a gradient if there are no values or level to assign to.
Seed colors are assigned to groups. If x is a character or factor and no by has been
specified, groups are the unique levels of x. If by is specified and is a character or
factor, or has fewer than 10 unique levels, groups are levels of by. If x is a list,
groups are list entries.
The number of variants for each seed color is determined either by a value (if the value has a length
of 1; e.g., x=10), the vector's length (if x is numeric), or the count of the given level
(if x is a factor or character vector).
A character vector of color codes, or a list of such vectors if flat if FALSE.
# including no arguments or just a palette name will only return
# the palette as a character vector
pastel_palette <- splot.color()
dark_palette <- splot.color("dark")
# entering a number for x will generate that many variants of the first seed color
red_scale <- splot.color(10, "red")
# entering a list of values as x will return that many variants of the associated seed
red_and_green_scales <- splot.color(list(10, 10), seed = c("red", "green"))
# this shows gradients of each color in the default palette
# a list entered as colorby is treated as arguments to splot.color
# periods before the position name refer to the internally assembled data
splot(
  rep(splot.color(), each = 100) ~ rep.int(seq.int(.01, 1, .01), 9),
  colorby = list(.x, .y),
  lines = FALSE, mar = c(2, 4, 0, 0), cex = c(points = 3), leg = FALSE, pch = 15,
  title = "'pastel' palette", labx = "value of x", laby = "seed color"
)
# colors graded by value, entered in a list
plot(
  1:30, numeric(30),
  pch = 15, cex = 10,
  col = splot.color(list(1:8, c(7:1, 1:7), 8:1))
)
# comparing sampling methods:
#   on top are 1000 similar colors, with different RGB ratios
#   on bottom are 268 colors with the same RGB ratio at different levels
splot(
  c(rnorm(1000), rnorm(1000, 10)) ~ rnorm(2000),
  lines = FALSE,
  colors = c(splot.color(1000), splot.color(1000, method = "related"))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.