Package 'rcartocolor'

Title: 'CARTOColors' Palettes
Description: Provides color schemes for maps and other graphics designed by 'CARTO' as described at <https://carto.com/carto-colors/>. It includes four types of palettes: aggregation, diverging, qualitative, and quantitative.
Authors: Jakub Nowosad [aut, cre]
Maintainer: Jakub Nowosad <[email protected]>
License: MIT + file LICENSE
Version: 2.1.2
Built: 2024-11-09 05:54:17 UTC
Source: https://github.com/nowosad/rcartocolor

Help Index


CARTOcolor palettes

Description

Creates a color palette from CARTOcolor

Usage

carto_pal(n = NULL, name, ...)

Arguments

n

Number of different colors in the palette, minimum depending on palette (2 or 3), maximum depending on palette (7 or 11)

name

A palette name

...

Additional arguments for grDevices::colorRampPalette

Value

A character vector

Examples

my_colors1 = carto_pal(7, "Burg")
my_colors1

my_colors2 = carto_pal(17, "Burg")
my_colors2

my_colors3 = carto_pal(17, "Safe")
my_colors3

CARTOColors database

Description

A dataset containing the information about the CARTOcolor palettes. Source: https://github.com/CartoDB/CartoColor/blob/master/cartocolor.js.

Usage

cartocolors

Format

A data frame with 32 rows and 12 variables:

  • Name: palette name

  • Type: palette type

  • n2 to n11: list of the color values depending on the number of colors used (between two and twelve)


CARTOcolor palettes viewer

Description

Displays a set of the color palettes from CARTOcolor

Usage

display_carto_all(n = NULL, type = "all", colorblind_friendly = NULL)

Arguments

n

Number of different colors in the palette, minimum depending on the palette (2 or 3), maximum depending on the palette (7 or 11)

type

Type of the palette, can be "quantitative", "diverging", "qualitative", "aggregation", or "all"

colorblind_friendly

if TRUE, display only colorblind friendly palettes

Examples

display_carto_all()
display_carto_all(type = "quantitative")
display_carto_all(type = c("diverging", "qualitative", "aggregation"))
display_carto_all(3, type = "quantitative")
display_carto_all(7, type = "quantitative")
display_carto_all(7, colorblind_friendly = TRUE)
display_carto_all(7, type = c("diverging", "qualitative", "aggregation"),
  colorblind_friendly = TRUE)

CARTOcolor palette viewer

Description

Displays a color palette from CARTOcolor

Usage

display_carto_pal(n = NULL, name)

Arguments

n

Number of different colors in the palette, minimum depending on palette (2 or 3), maximum depending on palette (7 or 11)

name

A palette name

Examples

display_carto_pal(7, "Burg")

CARTOColors database metadata

Description

A dataset containing the information about the CARTOcolor palettes. Source: https://github.com/CartoDB/CartoColor/blob/master/cartocolor.js.

Usage

metacartocolors

Format

A data frame with 32 rows and 12 variables:

  • Name: palette name

  • Type: palette type

  • Min_n: minimal number of colors in a given palette

  • Max_n: maximal number of colors in a given palette

  • Colorblind_friendly: is the palette colorblind friendly?


CARTO color scales

Description

CARTO color scales

Usage

scale_color_carto_c(
  ...,
  type = "quantitative",
  palette = 1,
  direction = 1,
  na.value = "#e9e9e9",
  guide = "colourbar"
)

scale_color_carto_d(
  ...,
  type = "qualitative",
  palette = 1,
  direction = 1,
  na.value = "#e9e9e9"
)

scale_colour_carto_c(
  ...,
  type = "quantitative",
  palette = 1,
  direction = 1,
  na.value = "#e9e9e9",
  guide = "colourbar"
)

scale_colour_carto_d(
  ...,
  type = "qualitative",
  palette = 1,
  direction = 1,
  na.value = "#e9e9e9"
)

scale_fill_carto_c(
  ...,
  type = "quantitative",
  palette = 1,
  direction = 1,
  na.value = "#e9e9e9",
  guide = "colourbar"
)

scale_fill_carto_d(
  ...,
  type = "qualitative",
  palette = 1,
  direction = 1,
  na.value = "#e9e9e9"
)

Arguments

...

Other arguments passed on to ggplot2::discrete_scale() or ggplot2::continuous_scale() to control name, limits, breaks, labels and so forth

type

One of \"aggregation\", \"diverging\", \"qualitative\", or \"quantitative\"

palette

If a string, will use that named palette. If a number, will index into the list of palettes of appropriate type

direction

Sets the order of colors in the scale. If 1, the default, colors are as output by carto_pal(). If -1, the order of colors is reversed

na.value

Missing values will be replaced with this value.

guide

A function used to create a guide or its name. See guides() for more information.

Examples

library(ggplot2)

ggplot(msleep, aes(vore, sleep_total, fill = vore)) +
        geom_boxplot() +
        scale_fill_carto_d(palette = 6, direction = -1)

## Not run: 
library(sf)
library(spData)
library(ggplot2)
ggplot(world, aes(fill = lifeExp)) +
        geom_sf(data = world) +
        coord_sf(crs = "+proj=robin") +
        scale_fill_carto_c(name = "Life expectancy: ",
                           type = "diverging", palette = "Earth", direction = -1) +
        theme_void()

ggplot(world, aes(fill = region_un)) +
        geom_sf(data = world) +
        coord_sf(crs = "+proj=robin")  +
        scale_fill_carto_d(name = "Region: ", palette = "Safe") +
        theme_void()

## End(Not run)