colorGrad | R Documentation |
Create a gradient of colors and optionally a colorbar
colorGrad(
n = 21,
colors = NULL,
space = c("rgb", "Lab"),
lo = "#18A3AC",
lomid = NULL,
mid = NULL,
midhi = NULL,
hi = "#F48024",
preview = FALSE,
colorbar = FALSE,
cb.n = 21,
cb.mar = c(1, 1, 1, 1),
cb.add = FALSE,
cb.add.mar = c(5, 0, 2, 5),
cb.axis.pos = 1.1,
cb.axis.las = 1,
cb.axis.hadj = 0,
cb.cex = 6,
bar.min = -1,
bar.mid = 0,
bar.max = 1,
cex = 1.2,
filename = NULL,
pdf.width = 3,
pdf.height = 7,
theme = getOption("rt.theme", "light"),
bg = NULL,
col.text = NULL,
plotlycb = FALSE,
plotly.width = 80,
plotly.height = 500,
rtrn.plotly = FALSE,
margins = c(0, 0, 0, 0),
pad = 0,
par.reset = TRUE
)
n |
Integer: How many distinct colors you want. If not odd, converted to |
colors |
Character: Acts as a shortcut to defining |
space |
Character: Which colorspace to use. Option: "rgb", or "Lab". Default = "rgb".
Recommendation: If |
lo |
Color for low end |
lomid |
Color for low-mid |
mid |
Color for middle of the range or "mean", which will result in |
midhi |
Color for middle-high |
hi |
Color for high end |
preview |
Logical: Plot the colors horizontally |
colorbar |
Logical: Create a vertical colorbar |
cb.n |
Integer: How many steps you would like in the colorbar |
cb.mar |
Vector, length 4: Colorbar margins. Default: c(1, 1, 1, 1) |
cb.add |
Logical: If TRUE, colorbar will be added to existing plot |
cb.add.mar |
Vector: Margins for colorbar (See |
cb.axis.pos |
Float: Position of axis (See |
cb.axis.las |
Integer 0,1,2,3: Style of axis labels. 0: Always parallel to the axis, 1: Horizontal, 2: Perpendicular, 3: Vertical. Default = 1 |
cb.axis.hadj |
Float: Adjustment parallel to the reading direction (See |
cb.cex |
FLoat: Character expansion factor for colorbar (See |
bar.min |
Numeric: Lowest value in colorbar |
bar.mid |
Numeric: Middle value in colorbar |
bar.max |
Numeric: Max value in colorbar |
cex |
Float: Character expansion for axis |
filename |
String (Optional: Path to file to save colorbar |
pdf.width |
Float: Width for PDF output. Default = 3 |
pdf.height |
Float: Height for PDF output. Default = 7 |
theme |
Character: "light", "dark" |
bg |
Color: Background color |
col.text |
Color: Colorbar text color |
plotlycb |
Logical: Create colorbar using |
plotly.width |
Float: Width for plotly colorbar. Default = 80 |
plotly.height |
Float: Height for plotly colorbar. Default = 500 |
rtrn.plotly |
Logical: If TRUE, return |
margins |
Vector: Plotly margins. Default = c(0, 0, 0, 0) |
pad |
Float: Padding for |
par.reset |
Logical: If TRUE (Default), reset |
It is best to provide an odd number, so that there is always an equal number of colors on either side of the midpoint. For example, if you want a gradient from -1 to 1 or equivalent, an n = 11, will give 5 colors on either side of 0, each representing a 20\
colors
can be defined as a sequence of 3-letter color abbreviations of 2, 3, 4, or 5 colors
which will correspond to values: {"lo","hi"}; {"lo", "mid", "hi"}; {"lo", "mid", "midhi", "hi"}, and
{"lo", "lomid", "mid", "midhi", "hi"}, respectively.
For example, try colorGrad(21, "blugrnblkredyel", colorbar = TRUE)
3-letter color abbreviations:
wht: white; blk: black; red; grn: green; blu: blue; yel: yellow; rng: orange; prl: purple
Invisible vector of hexadecimal colors / plotly object if rtrn.plotly = TRUE
E.D. Gennatas
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.