col_linear_xf | R Documentation |
Linear color interpolation function with adjustable range, baseline, and floor
col_linear_xf(
x = 1,
floor = 0,
baseline = 0,
lens = 0,
n = 6,
colramp = "Purples",
open_floor = FALSE,
debug = FALSE,
...
)
x |
|
floor |
|
baseline |
|
lens |
|
n |
|
colramp |
|
open_floor |
|
debug |
|
... |
additional arguments are ignored. |
This function is the linear equivalent of col_div_xf()
, in that
it takes linear/sequential color gradient instead of a divergent
color gradient.
Other colorjam gradients:
col_div_xf()
,
make_jam_divergent()
,
twostep_gradient()
Other colorjam assignment:
col_div_xf()
,
group2colors()
,
matrix2heatColors()
,
rainbowJamMulti()
,
vals2colorLevels()
,
vibrant_color_by_hue()
col_fn1 <- col_linear_xf(x=3, baseline=0, floor=0)
col_fn2 <- col_linear_xf(x=3, baseline=0, floor=1)
col_fn2o <- col_linear_xf(x=3, baseline=0, floor=1, open_floor=TRUE)
test_seq <- seq(from=0, to=3, by=0.05);
names(test_seq) <- round(test_seq, digits=2);
opar <- par("mfrow"=c(1, 1));
bp0 <- barplot(abs(test_seq),
las=2, yaxt="n",
main="floor=0",
col=col_fn1(test_seq),
border="#22222222")
abline(v=bp0[abs(test_seq) == 1,], lty="dashed")
bp1 <- barplot(abs(test_seq),
las=2, yaxt="n",
main="floor=1",
col=col_fn2(test_seq),
border="#22222222")
abline(v=bp1[abs(test_seq) == 1,], lty="dashed")
bp2 <- barplot(abs(test_seq),
las=2, yaxt="n",
main="floor=1\nopen_floor=TRUE",
col=col_fn2o(test_seq),
border="#22222222")
abline(v=bp2[abs(test_seq) == 1,], lty="dashed")
par(opar)
col_fn3 <- col_linear_xf(x=3, baseline=6, floor=5)
test_seq <- seq(from=0, to=7, by=0.1);
names(test_seq) <- round(test_seq, digits=2);
bp3 <- barplot(abs(test_seq),
las=2, yaxt="n",
main="baseline=6, x=3, floor=5",
col=col_fn3(test_seq),
border="#22222222")
abline(v=bp3[abs(test_seq) == 5,], lty="dashed")
abline(v=bp3[abs(test_seq) == 3,], lty="dashed")
# Optionally show how to display data and legend in ComplexHeatmap
if (jamba::check_pkg_installed("ComplexHeatmap")) {
set.seed(123);
m <- abs(matrix(ncol=9, rnorm(81) * 8));
col1 <- col_linear_xf(14, floor=4, n=8, lens=2);
hm_1 <- ComplexHeatmap::Heatmap(m, col=col1,
cell_fun=jamba::cell_fun_label(m=m, col_hm=col1),
heatmap_legend_param=list(
color_bar="discrete",
at=c(0, 2, 3.99, 4, 6, 8, 10, 12, 14),
border=TRUE),
column_title="col_linear_xf(14, floor=4)",
name="color key 1",
border=TRUE);
col2 <- col_linear_xf(14, floor=4, n=8, lens=2, open_floor=TRUE);
hm_2 <- ComplexHeatmap::Heatmap(m,
col=col2,
cell_fun=jamba::cell_fun_label(m=m, col_hm=col2),
heatmap_legend_param=list(
color_bar="discrete",
at=c(0, 2, 3.99, 4, 6, 8, 10, 12, 14),
border=TRUE),
column_title="col_linear_xf(14, floor=4, open_floor=TRUE)",
name="color key 2",
border=TRUE);
hm_1 + hm_2
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.