Yet another plot of R's colors()

I know there are plenty of these online, but I just thought about having my own for quick reference…

ncols <- ceiling(sqrt(length(colors())))^2
dat <- matrix(1:ncols, sqrt(ncols))
image(dat, col = colors()[1:ncols])
pos <- seq(0, 1, length.out = sqrt(ncols))
pos <- lapply(pos, function(x) cbind(x, pos))
pos <-, pos)

ncols <- length(colors())
text(x=pos[1:ncols,2], y=pos[1:ncols,1], labels = 1:ncols, cex=.75, srt=60)

comments powered by Disqus