scale_colour_2dii: Custom 2DII colour and fill scales

View source: R/scale_colour_2dii.R

scale_colour_2diiR Documentation

Custom 2DII colour and fill scales

Description

A custom discrete colour and fill scales with colours from 2DII palettes.

Usage

scale_colour_2dii(
  palette = c("2dii", "1in1000", "pacta", "survey"),
  colour_groups = NULL,
  labels = NULL,
  ...
)

scale_fill_2dii(
  palette = c("2dii", "1in1000", "pacta", "survey"),
  colour_groups = NULL,
  labels = NULL,
  ...
)

Arguments

palette

String with the name of the colour scale to be used. If not specified then the general 2dii scale is used

colour_groups

A vector containing groups variable to which colours are assigned. It is needed when the data assigned to colour aesthetic are not all contained in colour aliases of the palette. By default it is null and then only names in data that are also found in colour aliases for the palette are coloured.

labels

Labels parameter to be used in ggplot2::scale_colour_manual. By default it is set to an internal function beaudetifying the labels.

...

Other parameters passed on to ggplot2::discrete_scale().

Value

An object of class "ScaleDiscrete".

Examples

library(ggplot2, warn.conflicts = FALSE)
library(r2dii.plot, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)

sda %>%
  filter(emission_factor_metric == "projected") %>%
  ggplot() +
  geom_line(aes(x = year, y = emission_factor_value, colour = sector)) +
  scale_colour_2dii()

mpg %>%
  ggplot() +
  geom_histogram(aes(cyl, fill = class), position = "dodge", bins = 5) +
  scale_fill_2dii()

sda %>%
  filter(emission_factor_metric == "projected") %>%
  ggplot() +
  geom_line(aes(x = year, y = emission_factor_value, colour = sector)) +
  scale_colour_2dii(palette = "1in1000", colour_groups = sda$sector)

market_share %>%
  filter(sector == "automotive", year %in% c(2020, 2025), metric == "projected") %>%
  ggplot() +
  geom_bar(
    stat = "identity",
    aes(x = year, y = technology_share, fill = technology)
  ) +
  scale_fill_2dii(palette = "pacta")

2DegreesInvesting/r2dii.colours documentation built on May 7, 2024, 4:49 p.m.