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,
return_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".
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. |
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. |
pdf_height |
Float: Height for PDF output. |
theme |
Theme object. |
bg |
Color: Background color |
col_text |
Color: Colorbar text color |
plotlycb |
Logical: Create colorbar using |
plotly_width |
Float: Width for plotly colorbar. |
plotly_height |
Float: Height for plotly colorbar. |
return_plotly |
Logical: If TRUE, return |
margins |
Vector: Plotly margins. |
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 return_plotly = TRUE
EDG
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.