April, 2018
plot(1:20, y=rep(0,20), col = 1:20, cex = 2, pch = 20 )
head(colors())
## [1] "white" "aliceblue" "antiquewhite" "antiquewhite1" ## [5] "antiquewhite2" "antiquewhite3"
tail(colors())
## [1] "yellow" "yellow1" "yellow2" "yellow3" "yellow4" ## [6] "yellowgreen"
mycol = colors() plot(1:80, y=rep(1,80), col = mycol[1:80], cex = 2, pch = 20, ylim = c(0,1) ) points(1:80, y=rep(0.5,80), col = mycol[81:160], cex = 2, pch = 20 ) points(1:80, y=rep(0,80), col = mycol[161:240], cex = 2, pch = 20 )
mycol = colors() image(matrix(1:25^2,25,25), col = mycol)
maxColorValue = 255
.rgb(10, 4, 23, maxColorValue = 255, alpha = 10)
## [1] "#0A04170A"
col2rgb('lightblue')
## [,1] ## red 173 ## green 216 ## blue 230
hcl(h = 0, c = 35, l = 85, alpha = 0.1)
## [1] "#FFC5D01A"
hsv(0.3, 0.5, 0.1, alpha = 0.4)
## [1] "#0F1A0D66"
heat.colors(4, alpha = 1)
## [1] "#FF0000FF" "#FF8000FF" "#FFFF00FF" "#FFFF80FF"
topo.colors(4, alpha = 1)
## [1] "#4C00FFFF" "#00E5FFFF" "#00FF4DFF" "#FFFF00FF"
x <- 10*(1:nrow(volcano)) y <- 10*(1:ncol(volcano)) image(x, y, volcano, col = heat.colors(20, alpha = 1), axes = FALSE) contour(x, y, volcano, levels = seq(90, 200, by = 5), add = TRUE, col = 'white')
x <- 10*(1:nrow(volcano)) y <- 10*(1:ncol(volcano)) image(x, y, volcano, col = topo.colors(20, alpha = 1), axes = FALSE) contour(x, y, volcano, levels = seq(90, 200, by = 5), add = TRUE, col = 'white')
rainbow(5, s = 0.4, v = 0.3, start = 0, end = 0.05, alpha = 1)
## [1] "#4D2E2EFF" "#4D302EFF" "#4D322EFF" "#4D352EFF" "#4D372EFF"
library(RColorBrewer) brewer.pal(4, 'Blues')
## [1] "#EFF3FF" "#BDD7E7" "#6BAED6" "#2171B5"
x <- 10*(1:nrow(volcano)) y <- 10*(1:ncol(volcano)) image(x, y, volcano, col = brewer.pal(9, 'Blues'), axes = FALSE)
library(RColorBrewer) brewer.pal(4, 'BrBG')
## [1] "#A6611A" "#DFC27D" "#80CDC1" "#018571"
library(RColorBrewer) display.brewer.all()
library(colorspace)
## Warning: package 'colorspace' was built under R version 3.4.1
diverge_hcl(7, h = c(246, 40), c = 96, l = c(65, 90))
## [1] "#1FA4FF" "#97BFF3" "#CAD6E9" "#E2E2E2" "#E7D1C5" "#E9B18B" "#E28912"
library(colorspace) pal = choose_palette()