Skip to contents

plot a 'SpatRaster' or 'stars' object using {scico} palettes. View palette options with sciplot_pals()

Usage

sciplot(x, pal = "acton", n, direction, centre, ...)

# S3 method for SpatRaster
sciplot(
  x,
  pal = "acton",
  n = 256,
  direction = 1,
  centre = FALSE,
  n_quantile = NULL,
  ...
)

# S3 method for stars
sciplot(x, pal = "acton", n = 11, direction = 1, centre = FALSE, ...)

sciplot_pals()

Arguments

x

object to plot, either a SpatRaster or stars object

pal

Default is 'acton'. Character describing colour palette to use. choose from sciplot_pals()

n

Numeric of length 1. The number of breaks/colours to include in the sclae

direction

Default is 1. Direction of colour palette to reverse use -1.

centre

Logical. If TRUE, the palette is centred around zero. good for bivariate/split palettes.

...

additional args passed to plot.

n_quantile

Numeric. if not NULL sets the number of quantile breaks to use for sciplot.SpatRaster. See details.

Value

character vector of scico palette names. see scico::scico_palette_names()

Details

n_quantile sets quantile breaks for the colour palette. When using breaks, terra::plot does not support continuous legend as is the default in stars.

sciplot_pals plots the various sciplot palettes and returns their names as a character vector. Wrapper for scico::scico_palette_show() and scico::scico_palette_names().

Examples


src <- "/vsicurl/https://public.services.aad.gov.au/datasets/science/GEBCO_2021_GEOTIFF/GEBCO_2021.tif"
template <- ezgrid(c(-180, 180, -90, 90), c(720, 360), 'EPSG:4326')
world.el.terra <- ezwarp(x=src, y=template)
sciplot(world.el.terra, pal='oleron', centre=TRUE)


f <- system.file("ex/elev.tif", package="terra") 
r.stars <- stars::read_stars(f)
sciplot(r.stars)


sciplot_pals()

#>  [1] "acton"   "bam"     "bamako"  "bamO"    "batlow"  "batlowK" "batlowW"
#>  [8] "berlin"  "bilbao"  "broc"    "brocO"   "buda"    "bukavu"  "cork"   
#> [15] "corkO"   "davos"   "devon"   "fes"     "grayC"   "hawaii"  "imola"  
#> [22] "lajolla" "lapaz"   "lisbon"  "nuuk"    "oleron"  "oslo"    "roma"   
#> [29] "romaO"   "tofino"  "tokyo"   "turku"   "vanimo"  "vik"     "vikO"