| twostep_gradient | R Documentation |
Create two-step linear gradient by gradually blending two linear color gradients
twostep_gradient(
color1 = NULL,
color2 = NULL,
n = 11,
lite = TRUE,
defaultBaseColor = NULL,
adjust = 1.5,
do_fixYellow = TRUE,
debug = FALSE,
...
)
color1 |
|
color2 |
|
n |
|
lite |
|
defaultBaseColor |
|
adjust |
|
do_fixYellow |
|
debug |
|
... |
additional arguments are passed to |
This function is intended to produce a two-step linear gradient
effect, similar to the strategy used by RColorBrewer, but
without specific color constraints. See examples.
This function takes two color gradients and blends them
using a weighting scheme that begins with 100% color1, and
gradually becomes 100% color2.
The input color1 and color2 can be any input recognized
by jamba::getColorRamp(). For example a single color can
be used to create a gradient, or the name of a known color
gradient can be used, for example "Reds" will refer
to RColorBrewer palette "Reds". See the examples.
In general most gradients can be blended using this function to produce a new color gradient where both the visual intensity and color hue vary along the gradient, making each color step more visibly distinct than when only the visual intensity changes.
When supplying a single color as input to color1 or color2
it sometimes works best to alter the brightness of one or both
colors so the intermediate gradients have similar intensities.
Experimenting with debug=TRUE is recommended.
Other colorjam gradients:
col_div_xf(),
col_linear_xf(),
make_jam_divergent()
ts <- twostep_gradient("yellow", debug=TRUE)
ts1 <- twostep_gradient("orange2", "firebrick", n=11, debug=TRUE)
ts2 <- twostep_gradient("aquamarine", "dodgerblue", n=11, debug=TRUE)
# stitch them together with make_jam_divergent()
ts1ts2 <- make_jam_divergent(list(ts2=ts2), list(ts1=ts1), n=21)
jamba::showColors(ts1ts2)
ts1ts2flat <- make_jam_divergent("dodgerblue", "firebrick", n=21)
jamba::showColors(list(
twostep=ts1ts2[[1]],
flat=ts1ts2flat[[1]]))
ts3 <- twostep_gradient("Greens", "Blues", n=11, debug=TRUE)
ts4 <- twostep_gradient("slateblue2", "firebrick", n=11, debug=TRUE)
ts5 <- twostep_gradient("cividis", "inferno", n=11, debug=TRUE, adjust=-1.2)
gr1 <- twostep_gradient("slateblue", "purple", debug=TRUE)
gr2 <- twostep_gradient("gold", "darkorange", debug=TRUE)
div12 <- make_jam_divergent(list(gr1=gr1), list(gr2=gr2))
jamba::showColors(div12)
div12flat <- make_jam_divergent("purple", "gold")
jamba::showColors(list(
twostep=div12[[1]],
flat=div12flat[[1]]))
gr1d <- twostep_gradient("slateblue1", "purple", debug=TRUE, lite=FALSE)
gr2d <- twostep_gradient("darkorange", "gold", debug=TRUE, lite=FALSE)
div12d <- make_jam_divergent(list(gr1d=gr1d), list(gr2d=gr2d))
jamba::showColors(div12d)
div12dflat <- make_jam_divergent("purple", "gold", lite=FALSE)
jamba::showColors(list(
twostep=div12d[[1]],
flat=div12dflat[[1]]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.