c4a | R Documentation |
Get a cols4all color palette: c4a
returns the colors of the specified palette, c4a_na
returns the color for missing value that is associated with the specified palette, and c4a_ramp
returns a color ramp function. Run c4a_gui
to see all available palettes, which are also listed with c4a_palettes
.
c4a(
palette = NULL,
n = NA,
m = NA,
type = c("cat", "seq", "div", "cyc", "bivs", "bivc", "bivd", "bivg"),
reverse = FALSE,
order = NULL,
range = NA,
colorsort = "orig",
format = c("hex", "rgb", "hcl", "RGB", "XYZ", "HSV", "HLS", "LAB", "polarLAB", "LUV",
"polarLUV"),
nm_invalid = c("error", "repeat", "interpolate"),
verbose = TRUE
)
c4a_ramp(..., space = c("rgb", "Lab"), interpolate = c("linear", "spline"))
c4a_na(
palette = NULL,
type = c("cat", "seq", "div", "cyc", "bivs", "bivc", "bivd", "bivg"),
verbose = TRUE
)
palette |
name of the palette. See |
n |
number of colors. If omitted then: for type |
m |
number of rows in case type is bivariate, so one of |
type |
type of color palette, in case |
reverse |
should the palette be reversed? |
order |
order of colors. Only applicable for |
range |
a vector of two numbers between 0 and 1 that determine the range that is used for sequential and diverging palettes. The first number determines where the palette begins, and the second number where it ends. For sequential |
colorsort |
Sort the colors. Options: |
format |
format of the colors. One of: |
nm_invalid |
what should be done in case |
verbose |
should messages be printed? |
... |
passed on to |
space |
a character string; interpolation in RGB or CIE Lab color spaces |
interpolate |
use spline or linear interpolation |
A vector of colors (c4a
) and a color (c4a_na
)
# get the colors from brewer.set3 and plot them
set3 <- c4a("brewer.set3")
c4a_plot_hex(set3, nrows = 1)
c4a("hcl.set2", n = 36) |> c4a_plot_hex()
c4a("-hcl.set2", n = 12) |> c4a_plot_hex()
# how to know which palettes are avaiable?
# 1) Via the interactive tool:
## Not run:
c4a_gui()
## End(Not run)
# 2) Via the overview function:
c4a_palettes(type = "cat")
c4a_palettes(series = "brewer")
c4a_palettes(type = "cat", series = "brewer")
# Run c4a_overview() to see which are available
# 3) Via .P
.P$brewer$cat$set3
# each palette contains a color for missing values
c4a("carto.safe", 7)
c4a_na("carto.safe")
c4a_plot_hex("carto.safe", n = 7, include.na = TRUE)
c4a_plot_hex("carto.safe", n = 7, include.na = TRUE)
# same (but shorter) as
# c4a_plot_hex(c(c4a("carto.safe", 7), c4a_na("carto.safe")), include.na = TRUE)
# color ramp
c4a("viridis", 100) |> c4a_plot()
c4a_ramp("viridis")(100) |> c4a_plot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.