ggplot2: cmocean colour scales for ggplot2

Description Usage Arguments Value Author(s) See Also Examples

Description

Helper functions to allow the colour scale to be used effectively in ggplot2.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  scale_colour_cmocean(
    ..., alpha = 1, start = 0, end = 1, direction = 1, discrete = FALSE,
    name = "thermal", version = getOption('cmocean-version', '2.0')
  )
  scale_color_cmocean(
    ..., alpha = 1, start = 0, end = 1, direction = 1, discrete = FALSE,
    name = "thermal", version = getOption('cmocean-version', '2.0')
  )
  scale_fill_cmocean(
    ..., alpha = 1, start = 0, end = 1, direction = 1, discrete = FALSE,
    name = "thermal", version = getOption('cmocean-version', '2.0')
  )

Arguments

...

parameters to ggplot2 functions discrete_scale or scale_fill_gradientn.

alpha

opacity of the palette in the range [0, 1].

start

fraction of the colormap to clip from its start, in [0, 1].

end

fraction of the colormap where it should stop, in [0, 1]; start < end.

direction

set to -1 to reverse the palette.

discrete

set to TRUE to generate a discrete palette instead of a continuous one.

name

the name of one of the available cmocean colormaps, see cmocean for the full list.

version

specific cmocean version you would like to use, passed as-is to cmocean. Defaults to the latest available version of the palette set.

Value

A ggplot object to be used with other ggplot objects.

Author(s)

As requested by Ilja Kocken in https://github.com/aitap/cmocean/issues/5.

See Also

cmocean

Examples

1
2
3
4
5
6
7
8
if (require('ggplot2')) {
  dat <- data.frame(
    a = 1:10, b = 11:20, c = rnorm(10)
  )

  ggplot(dat, aes(x = a, y = b, fill = c)) +
  geom_raster() + scale_fill_cmocean()
}

cmocean documentation built on Nov. 19, 2020, 1:08 a.m.