Description Usage Arguments Details Value Examples
makecolors
Generates color labels and legends for factors.
1 | makecolors(object, pal = cbbPalette, keep.order = TRUE)
|
object |
A matrix of vector that can be coerced into factors. |
pal |
A vector of colors. |
keep.order |
Logical. Keep original order of non-factor strings. |
The function accepts either a vector that can be coerced into factors or a matrix where each column is used to generate color labels.
Can also be generate unique pch
labels (see Examples).
A list containing:
A unique vector/color pair for easy legend plotting.
A matrix or vector of colors for plotting.
1 2 3 4 5 6 7 8 | x <- factor(sample(c('a','b','c'), 30, replace = TRUE))
colset <- makecolors(x)
xnum <- jitter(as.numeric(x))
plot(xnum, col = colset$Colors, pch = 16)
legend('topright', legend = names(colset$Legend), col = colset$Legend, pch = 16)
pchset <- makecolors(x, pal = c(16,17,18))$Colors
plot(xnum, col = colset$Colors, pch = pchset)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.