Learn R Programming

cmocean (version 0.3-2)

scale_colour_cmocean: 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')
  )

Value

A ggplot object to be used with other ggplot objects.

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.

Author

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

See Also

cmocean

Examples

Run this code
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()
}

Run the code above in your browser using DataLab