Package 'scico'

Title: Colour Palettes Based on the Scientific Colour-Maps
Description: Colour choice in information visualisation is important in order to avoid being mislead by inherent bias in the used colour palette. The 'scico' package provides access to the perceptually uniform and colour-blindness friendly palettes developed by Fabio Crameri and released under the "Scientific Colour-Maps" moniker. The package contains 24 different palettes and includes both diverging and sequential types.
Authors: Thomas Lin Pedersen [aut, cre] , Fabio Crameri [aut]
Maintainer: Thomas Lin Pedersen <[email protected]>
License: MIT + file LICENSE
Version: 1.5.0.9000
Built: 2024-11-10 04:29:33 UTC
Source: https://github.com/thomasp85/scico

Help Index


scico: Colour Palettes Based on the Scientific Colour-Maps

Description

logo

Colour choice in information visualisation is important in order to avoid being mislead by inherent bias in the used colour palette. The 'scico' package provides access to the perceptually uniform and colour-blindness friendly palettes developed by Fabio Crameri and released under the "Scientific Colour-Maps" moniker. The package contains 24 different palettes and includes both diverging and sequential types.

Author(s)

Maintainer: Thomas Lin Pedersen [email protected] (ORCID)

Authors:

  • Fabio Crameri

See Also

Useful links:


Scales to use for ggplot2

Description

These functions provide the option to use the scico palettes along with the ggplot2 package. It goes without saying that it requires ggplot2 to work.

Usage

scale_colour_scico(
  ...,
  alpha = NULL,
  begin = 0,
  end = 1,
  direction = 1,
  palette = "bilbao",
  midpoint = NA
)

scale_color_scico(
  ...,
  alpha = NULL,
  begin = 0,
  end = 1,
  direction = 1,
  palette = "bilbao",
  midpoint = NA
)

scale_fill_scico(
  ...,
  alpha = NULL,
  begin = 0,
  end = 1,
  direction = 1,
  palette = "bilbao",
  midpoint = NA
)

scale_colour_scico_d(
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  palette = "batlow",
  aesthetics = "colour"
)

scale_color_scico_d(
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  palette = "batlow",
  aesthetics = "colour"
)

scale_fill_scico_d(
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  palette = "batlow",
  aesthetics = "fill"
)

Arguments

...

Arguments to pass on to ggplot2::scale_colour_gradientn(), ggplot2::scale_fill_gradientn(), ⁠ggplot2::ggplot2::discrete_scale()⁠

alpha

The opacity of the generated colours. If specified rgba values will be generated. The default (NULL) will generate rgb values which corresponds to alpha = 1

begin, end

The interval within the palette to sample colours from. Defaults to 0 and 1 respectively

direction

Either 1 or -1. If -1 the palette will be reversed

palette

The name of the palette to sample from. See scico_palette_names() for a list of possible names

midpoint

A midpoint to center the scale on, used primarily for diverging and multisequential scales

aesthetics

Character string or vector of character strings listing the name(s) of the aesthetic(s) that this scale works with. This can be useful, for example, to apply colour settings to the colour and fill aesthetics at the same time, via aesthetics = c("colour", "fill").

Value

A ScaleContinuous or ScaleDiscrete object that can be added to a ggplot object

Examples

if (require('ggplot2')) {
  volcano <- data.frame(
    x = rep(seq_len(ncol(volcano)), each = nrow(volcano)),
    y = rep(seq_len(nrow(volcano)), ncol(volcano)),
    height = as.vector(volcano)
  )
  
  ggplot(volcano, aes(x = x, y = y, fill = height)) + 
    geom_raster() + 
    scale_fill_scico(palette = 'tokyo') 
    
  ggplot(iris, aes(x=Petal.Width, y=Petal.Length)) +
    geom_point(aes(color=Species), size=10) + 
    scale_colour_scico_d() 
}

Scientific colour map palettes

Description

This function constructs palettes of the specified size based on the colour maps developed by Fabio Crameri. It follows the same API style as viridis() from the viridisLite package so anyone familiar with this package can easily adapt to that.

Usage

scico(
  n,
  alpha = NULL,
  begin = 0,
  end = 1,
  direction = 1,
  palette = "bilbao",
  categorical = FALSE
)

Arguments

n

The number of colours to generate for the palette

alpha

The opacity of the generated colours. If specified rgba values will be generated. The default (NULL) will generate rgb values which corresponds to alpha = 1

begin, end

The interval within the palette to sample colours from. Defaults to 0 and 1 respectively

direction

Either 1 or -1. If -1 the palette will be reversed

palette

The name of the palette to sample from. See scico_palette_names() for a list of possible names

categorical

Boolean. Should the categorical palettes be returned

Value

A character vector of length n with hexencoded rgb(a) colour values

References

http://www.fabiocrameri.ch/colourmaps.php

Crameri, Fabio. (2021, September 12). Scientific colour maps (Version 7.0.1). Zenodo. doi:10.5281/zenodo.5501399 Crameri, Fabio. (2018). Geodynamic diagnostics, scientific visualisation and StagLab 3.0. Geosci. Model Dev. Discuss. doi:10.5194/gmd-2017-328

Examples

# Use the default palette
scico(15)

# Flip the direction
scico(15, direction = -1)

# Take a subset of a palette
scico(15, begin = 0.3, end = 0.6, palette = 'berlin')

Show the different scico palettes

Description

This is a simple function to show a gradient of the different palettes available in the scico package

Usage

scico_palette_show(
  palettes = scico_palette_names(categorical),
  categorical = FALSE,
  n = if (categorical) 6 else 100
)

Arguments

palettes

One or more palette names to show

categorical

Boolean. Should the categorical palettes be returned

n

How many colours should be shown

Examples

scico_palette_show()
scico_palette_show(categorical = TRUE)