Skip to contents

Turn vector to color vector

Usage

color(col)

colour(col)

Arguments

col

a color object or vector of any of the three kinds of R color specifications, i.e., either a color name (as listed by colors()), a hexadecimal string of the form "#rrggbb" or "#rrggbbaa" (see rgb), or a positive integer i meaning palette()[i].

Value

a colors object.

Details

Alpha values will be automatically added to hexcodes. If none at present it will default to no alpha (FF).

Examples

terrain_10 <- color(terrain.colors(10))

terrain_10[1:4]
#> <colors>
#> #00A600FF #2DB600FF #63C600FF #A0D600FF 

plot(terrain_10)


plot(terrain_10, labels = TRUE)


grey_10 <- color(gray.colors(10, start = 0, end = 1))

grey_10
#> <colors>
#> #000000FF #5E5E5EFF #818181FF #9B9B9BFF #B0B0B0FF #C3C3C3FF #D4D4D4FF #E3E3E3FF #F2F2F2FF #FFFFFFFF 

plot(grey_10, labels = TRUE)