Search notes:

R: palettes

A palette is basically a vector of colors.

Some palletes

The following example shows some palettes drawn with raster:
library(RColorBrewer)
library(viridis)
library(raster)

nofColors <- 8;

palettes <- c(
      rainbow       (nofColors),
      palette       (         ), # palette has 8 colors
      heat.colors   (nofColors),
      terrain.colors(nofColors),
      topo.colors   (nofColors),
      cm.colors     (nofColors),
      viridis       (nofColors)
);

nofPalettes <- length(palettes) / nofColors;

grid <- raster(
            ncols =  nofColors,
            nrows =  nofPalettes,
            xmn   =  0,
            xmx   =  nofColors,
            ymn   =  0,
            ymx   =  nofPalettes
);

values(grid) <- 1:(nofPalettes * nofColors)

par(mar=rep(0.5, 4))

plot(grid,
    col    = palettes,
    legend = FALSE,
    axes   = 0,
    box    = FALSE
);
Github repository about-r, path: /graphics/coloring/palettes/some.R

See also

Coloring graphics with R
The packages

Links

https://stat.ethz.ch/R-manual/R-devel/RHOME/library/grDevices/html/palettes.html

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745511320, '3.142.53.191', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/graphics/coloring/palettes/index(98): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78