R base

R provides with some base palettes:

show_palette <- function(colors) {
  image(1:n, 1, as.matrix(1:n), col = colors, 
    xlab = "", ylab = "", xaxt = "n", 
    yaxt = "n", bty = "n")
}

n <- 6
show_palette(rainbow(n))

show_palette(heat.colors(n))

show_palette(terrain.colors(n))

show_palette(topo.colors(n))

show_palette(cm.colors(n))

There also a alpha parameter, from [0,1] for transparency.

par(mfrow=c(1,2))
show_palette(rainbow(n, alpha=0.33))
show_palette(rainbow(n, alpha =0.66))

For greyscales:

n <- 20
greys <- grey(seq(0, 1, length = n))
show_palette(greys)

RColorBrewer

Ref

Cindy Brewer website helps you choose the appropriate color scale for you map depending on your data type: qualitative, sequential or diverging (with a neutral color between two extremes).

There are 3 types of palettes, sequential, diverging, and qualitative.

# install: install.packages('RColorBrewer')
library(RColorBrewer)

display.brewer.all() 

To get the colors of a given palette:

brewer.pal(11,"Spectral")
##  [1] "#9E0142" "#D53E4F" "#F46D43" "#FDAE61" "#FEE08B" "#FFFFBF" "#E6F598"
##  [8] "#ABDDA4" "#66C2A5" "#3288BD" "#5E4FA2"
display.brewer.pal(11,"Spectral")

ggplot2 can use these palettes via the scale_brewer option.