cpt: Function to return colour palettes functions from 'cpt-city'

View source: R/cpt.R

cptR Documentation

Function to return colour palettes functions from 'cpt-city'

Description

This function return a collor palette based on the name or position of the palette.

Usage

cpt(
  pal = "mpl_inferno",
  n = 100,
  colorRampPalette = FALSE,
  rev = FALSE,
  alpha = NULL,
  frgb = rep(1, 3),
  matrix = F
)

Arguments

pal

Palette of colors available or the number of the position

n

integer; number of colors

colorRampPalette

Logical; to be used in sf and mapview.

rev

Logical; to internally revert order of rgb color vectors.

alpha

level of transparency between 0 and 1, default 1.

frgb

Numeric; vector of 3 to change internal rgb composition. The order is red, green, blue

matrix

Logical, to return the rgb matrix or not

Details

The cpt-city web archive comes from: http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html

Value

A colour palette function.

Examples

{
library(cptcity)
m <- cpt(pal = "colo_alpen_sky_rain_brolly", matrix = TRUE)
col <- rgb(red = m$r,
           green = m$g,
           blue = m$b,
           alpha = 1)

image(matrix(1:100), col = col)

# n = 100 by default

image(matrix(1:100), col = cpt(pal = "colo_alpen_sky_rain_brolly"))

find_cpt("temperature")
image(matrix(1:100), col = cpt("idv_temperature"))
image(matrix(1:100), col = cpt("idv_temperature", rev = TRUE))
# now you can select more than one palette!!!
image(matrix(1:100),
     col = cpt(pal = c("idv_temperature",
                       "arendal_temperature"),
               rev = TRUE))
## Not run: 
# Do not run
library(ggplot2)
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density))

 ggplot(faithfuld, aes(waiting, eruptions)) +
 geom_raster(aes(fill = density)) +
 scale_fill_gradientn(colours = cpt(n = 100))

## End(Not run)
}

ibarraespinosa/cptcity documentation built on Sept. 1, 2022, 11:19 a.m.