mypalette: A nice, pastel color palette

Description Usage Arguments Details Value Examples

View source: R/mypalette.R

Description

A nice, pastel color palette

Usage

1
2
3
4
5
mypalette(n = NULL, transparent = "99", alpha = NULL)

f2pal(f, palfunc = mypalette, ...)

f2leg(f, palfunc = mypalette, ...)

Arguments

n

length of palette to return. If longer than the number of colors in the return value of mypalette without any parameters, colors will be reused.

transparent

a character value to be pasted to each of the RGB color specifications in the palette indicating transparency ("00" for full transparency, "ff" for full opacity)

alpha

same as "transparent", but an alphanumeric value from 0..1. Takes precedence over "transparent"

f

a vector

Details

A nice, pastel color palette. The f2pal and f2leg convert factors to colors. f2pal converts a factors to colors directly, while f2pal returns a data frame with one column corresponding to factor levels, and another to the respective colors. This way it is possible to use it in legends. If the parameter f is not a factor, it will be converted to a factor.

Value

mypalette returns character vector with RGB color specifications. f2pal returns a character vector of RGB colors. f2leg returns a data frame with columns "text" and "col"

Examples

1
2
3
4
5
let <- sample(LETTERS[1:4], 50, replace=TRUE)
col <- f2pal(let)
plot(runif(50), runif(50), pch=19, col=col, cex=2)
leg <- f2leg(let)
legend("topleft", leg$text, pch=19, col=leg$col)

january3/myfuncs documentation built on April 1, 2020, 4:42 a.m.