Create a Palette of Colours

Description

Create a palette of colours.

Usage

1
oce.colorsTwo(n, low = 2/3, high = 0, smax = 1, alpha = 1)

Arguments

n

the number of colours (>=1) to be in the palette.

low

the hue, in [0,1], for the low end of a oce.colorsTwo scale.

high

the hue, in [0,1], for the high end of a oce.colorsTwo scale.

smax

the maximum saturation, in [0,1], for the colours of oce.colorsTwo.

alpha

the alpha value, in [0,1], for the colours of oce.colorsTwo.

Details

oce.colorsPalette provides a variety of pre-defined palettes. which=1 yields the ColorBrewer diverging red/blue scheme while which=2 yields the ColorBrewer diverging RYB scheme [1].

A family of nine-colour schemes is as follows: which="jet" (or which="9A" or which=9.01 for the Jet scheme; which="9B" or which=9.02 for a scheme similar to Jet but omitting the green, and somewhat desaturating the yellow and cyan.

oce.colorsGebco provides palettes that mimic the GEBCO atlas colours, with shades of blue for water and of brown for land. The blue values go from dark to light, and the brown ones from light to dark; in this way, topographic images have light values near sea-level, and get darker in either deeper water or higher terrain.

oce.colorsJet provides a palette similar to the Matlab “jet” palette.

oce.colorsTwo provides a two-tone palette that fades to white at central values.

oce.colorsViridis provides a matplotlib (python) colour scheme that became the standard in 2015; see [2]. This is a blue-yellow transition that is designed to reproduce well in black-and-white, and also to be interpretable by those with certain forms of colour blindness [3,4,5].

oce.colorsCDOM, oce.colorsChlorophyll, oce.colorsDensity, oce.colorsFreesurface, oce.colorsOxygen, oce.colorspAR, oce.colorsPhase, oce.colorsSalinity, oce.colorsTemperature, oce.colorsTurbidity, oce.colorsVelocity and oce.colorsVorticity are based on RGB values set up by Kristen M. Thyng for her Python package named cmcolor [7].

Author(s)

Dan Kelley

References

[1] Color Brewer. http://colorbrewer2.org/

[2] A blog item on the Viridis (and related) matplotlib colour scales is at http://bids.github.io/colormap/.

[3] Light, A., and P. J. Bartlein, 2004. The End of the Rainbow? Color Schemes for Improved Data Graphics. Eos Trans. AGU, 85(40), doi:10.1029/2004EO400002.

[4] Martin Jakobsson, Ron Macnab, and Members of the Editorial Board, IBCAO. Selective comparisons of GEBCO (1979) and IBCAO (2000) maps. http://www.ngdc.noaa.gov/mgg/bathymetry/arctic/ibcao_gebco_comp.html (link last checked 2016-06-12).

[5] Stephenson, David B., 2005. Comment on “Color schemes for improved data graphics,” by A. Light and P. J. Bartlein. Eos Trans. AGU, 86(20).

[6] The Geography department at the University of Oregon has good resources on colour schemes; see e.g. http://geography.uoregon.edu/datagraphics/color_scales.htm (This URL worked prior to December 8, 2015, but was found to fail on that date; it is included here in case users want to search for themselves.)

[7] The cmocean Python package, written by Kristen M Thyng, is available at https://github.com/kthyng/cmocean.

See Also

Other things related to colors: colormap, colors, oce.colorsGebco

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
library(oce)
opar <- par(no.readonly = TRUE)
# 1. Show a few palettes
x <- array(1:1000, dim=c(1,1000))
par(mfrow=c(1,5), mar=c(1, 3, 3, 1))
image(x, col=oce.colorsTwo(200), main="oce.colorsTwo")
image(x, col=oce.colorsJet(200), main="oce.colorsJet")
image(x, col=oce.colorsGebco(200), main="oce.colorsGebco")
image(x, col=oce.colorsPalette(200), main="oce.colorsPalette")
image(x, col=oce.colorsViridis(200), main="oce.colorsViridis")

# 4. Kristen M Thyng's 'cmocean' colours, specialised for oceanography.
par(mfrow=c(3,4), mar=c(1, 3, 3, 1))
image(x, col=oce.colorsCDOM(200), main="oce.colorsCDOM")
image(x, col=oce.colorsChlorophyll(200), main="oce.colorsChlorophyll")
image(x, col=oce.colorsDensity(200), main="oce.colorsDensity")
image(x, col=oce.colorsFreesurface(200), main="oce.colorsFreesurface")
image(x, col=oce.colorsOxygen(200), main="oce.colorsOxygen")
image(x, col=oce.colorsPAR(200), main="oce.colorsPAR")
image(x, col=oce.colorsPhase(200), main="oce.colorsPhase")
image(x, col=oce.colorsSalinity(200), main="oce.colorsSalinity")
image(x, col=oce.colorsTemperature(200), main="oce.colorsTemperature")
image(x, col=oce.colorsTurbidity(200), main="oce.colorsTurbidity")
image(x, col=oce.colorsVelocity(200), main="oce.colorsVelocity")
image(x, col=oce.colorsVorticity(200), main="oce.colorsVorticity")
 
# 3. Acoustic-Doppler profiler data; note that plot,adp-method() puts makes
# zlim be symmetric about zero velocity.
par(mfrow=c(1,1))
data(adp)
plot(adp, which='u1')

# 4. Contrast Jet with Viridis, using standard Volcano dataset;
# try printing the results in black and white.
par(mfrow=c(2,1))
imagep(volcano, col=oce.colorsJet)
imagep(volcano, col=oce.colorsViridis)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.