pal <- color_loon()
pal(letters[1:4])
pal(c('a','a','b','c'))
pal(c('green', 'yellow'))
# show color choices for different n's
if (requireNamespace("grid", quietly = TRUE)) {
grid::grid.newpage()
grid::pushViewport(grid::plotViewport())
grid::grid.rect()
n <- c(2,4,8,16, 21)
# beyond this, colors are generated algorithmically
# generating a warning
grid::pushViewport(grid::dataViewport(xscale=c(0, max(n)+1),
yscale=c(0, length(n)+1)))
grid::grid.yaxis(at=c(1:length(n)), label=paste("n =", n))
for (i in rev(seq_along(n))) {
cols <- pal(1:n[i])
grid::grid.points(x = 1:n[i], y = rep(i, n[i]),
default.units = "native", pch=15,
gp=grid::gpar(col=cols))
}
grid::grid.text("note the first i colors are shared for each n",
y = grid::unit(1,"npc") + grid::unit(1, "line"))
}
Run the code above in your browser using DataLab