ggplot2: cmocean colour scales for ggplot2

scale_colour_cmoceanR Documentation

cmocean colour scales for ggplot2

Description

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

Usage

  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]; \mathtt{start} < \mathtt{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

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 Sept. 11, 2024, 6:06 p.m.