colormap: A package to generate colors from a list of 44 pre-defined...

Description Usage Arguments Value Author(s) Examples

View source: R/colormap.R

Description

A package to generate colors from a list of 44 pre-defined palettes

Generate colors from a list of 44 palettes

Usage

1
2
colormap(colormap = colormaps$viridis, nshades = 72, format = "hex",
  alpha = 1, reverse = FALSE)

Arguments

colormap

A string, vector of hex color codes, or a list. Use the colormaps for a list of pre-defined palettes. OR A vector of colors in hex e.g. c('#000000','#777777','#FFFFFF') OR A list of list e.g. list(list(index=0,rgb=c(255,255,255)),list(index=1,rgb=c(255,0,0))) The index should go from 0 to 1. see https://www.npmjs.com/package/colormap#options

nshades

A number. Number of colors to generate.

format

A string. Should be 'hex', 'rgb', or 'rgbaString'

alpha

A Number between 0 and 1

reverse

Boolean. Whether to reverse the order.

Value

Colors either in vector, matrix, list format depending on format.

Author(s)

Bhaskar V. Karambelkar

Examples

1
2
3
4
5
6
7
8
colormap() # Defaults to 72 colors from the 'viridis' palette.
colormap(colormap=colormaps$temperature, nshades=20) # Diff Palette
colormap(colormap=c('#000000','#FF0000'), nshades=20) # Colormap as vector of colors
# list of list. Maximum flexibility
colormap(colormap=list(list(index=0,rgb=c(0,0,0)),list(index=1,rgb=c(255,255,255))), nshades=10)
colormap(format='rgb',nshades=10) # As rgb
colormap(format='rgb',nshades=10,alpha=0.5) # Constant alpha
colormap(format='rgbaString',nshades=10) # As rgba string

Example output

 [1] "#440154ff" "#440558ff" "#450a5cff" "#450e60ff" "#451465ff" "#461969ff"
 [7] "#461d6dff" "#462372ff" "#472775ff" "#472c7aff" "#46307cff" "#45337dff"
[13] "#433880ff" "#423c81ff" "#404184ff" "#3f4686ff" "#3d4a88ff" "#3c4f8aff"
[19] "#3b518bff" "#39558bff" "#37598cff" "#365c8cff" "#34608cff" "#33638dff"
[25] "#31678dff" "#2f6b8dff" "#2d6e8eff" "#2c718eff" "#2b748eff" "#29788eff"
[31] "#287c8eff" "#277f8eff" "#25848dff" "#24878dff" "#238b8dff" "#218f8dff"
[37] "#21918dff" "#22958bff" "#23988aff" "#239b89ff" "#249f87ff" "#25a186ff"
[43] "#25a584ff" "#26a883ff" "#27ab82ff" "#29ae80ff" "#2eb17dff" "#35b479ff"
[49] "#3cb875ff" "#42bb72ff" "#49be6eff" "#4ec16bff" "#55c467ff" "#5cc863ff"
[55] "#61c960ff" "#6bcc5aff" "#72ce55ff" "#7cd04fff" "#85d349ff" "#8dd544ff"
[61] "#97d73eff" "#9ed93aff" "#a8db34ff" "#b0dd31ff" "#b8de30ff" "#c3df2eff"
[67] "#cbe02dff" "#d6e22bff" "#e1e329ff" "#eae428ff" "#f5e626ff" "#fde725ff"
 [1] "#042333ff" "#0c2a50ff" "#13306dff" "#253582ff" "#403891ff" "#593d9cff"
 [7] "#6b4596ff" "#7e4e90ff" "#90548bff" "#a65c85ff" "#b8627dff" "#cc6a70ff"
[13] "#de7065ff" "#eb8055ff" "#f68f46ff" "#f9a242ff" "#f9b641ff" "#f7cb44ff"
[19] "#efe350ff" "#e8fa5bff"
 [1] "#000000ff" "#0d0000ff" "#1a0000ff" "#280000ff" "#350000ff" "#430000ff"
 [7] "#500000ff" "#5e0000ff" "#6b0000ff" "#790000ff" "#860000ff" "#940000ff"
[13] "#a10000ff" "#af0000ff" "#bc0000ff" "#ca0000ff" "#d70000ff" "#e50000ff"
[19] "#f20000ff" "#ff0000ff"
 [1] "#000000ff" "#1c1c1cff" "#383838ff" "#555555ff" "#717171ff" "#8e8e8eff"
 [7] "#aaaaaaff" "#c7c7c7ff" "#e3e3e3ff" "#ffffffff"
      [,1] [,2] [,3] [,4]
 [1,]   68    1   84    1
 [2,]   71   39  117    1
 [3,]   62   72  135    1
 [4,]   49  102  141    1
 [5,]   38  130  141    1
 [6,]   36  157  136    1
 [7,]   55  181  120    1
 [8,]  109  204   88    1
 [9,]  176  221   49    1
[10,]  253  231   37    1
      [,1] [,2] [,3] [,4]
 [1,]   68    1   84  0.5
 [2,]   71   39  117  0.5
 [3,]   62   72  135  0.5
 [4,]   49  102  141  0.5
 [5,]   38  130  141  0.5
 [6,]   36  157  136  0.5
 [7,]   55  181  120  0.5
 [8,]  109  204   88  0.5
 [9,]  176  221   49  0.5
[10,]  253  231   37  0.5
 [1] "rgba(68,1,84,1)"    "rgba(71,39,117,1)"  "rgba(62,72,135,1)" 
 [4] "rgba(49,102,141,1)" "rgba(38,130,141,1)" "rgba(36,157,136,1)"
 [7] "rgba(55,181,120,1)" "rgba(109,204,88,1)" "rgba(176,221,49,1)"
[10] "rgba(253,231,37,1)"

colormap documentation built on May 2, 2019, 10:22 a.m.

Related to colormap in colormap...