party_colour: Colours for Canadian Political Parties

Description Usage Arguments Format Examples

View source: R/scale_party.R

Description

Colours for Canadian Political Parties

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
party_colour(
  party,
  party_colours = canadian_party_colours(),
  palette_extra = scales::hue_pal(),
  na.value = "grey50"
)

pal_party(
  party = character(0),
  party_colours = canadian_party_colours(),
  palette_extra = scales::hue_pal()
)

scale_colour_party(
  ...,
  party_colours = canadian_party_colours(),
  palette_extra = scales::hue_pal(),
  aesthetics = "colour"
)

scale_fill_party(
  ...,
  party_colours = canadian_party_colours(),
  palette_extra = scales::hue_pal(),
  aesthetics = "fill"
)

canadian_party_colours()

ScaleParty

Arguments

party

A vector of party names like those seen in the party column of results.

party_colours

Known party colours, like those returned by canadian_party_colours().

palette_extra

A palette for assigning colours to rare parties like scales::hue_pal().

na.value

The colour to be used for NA values.

aesthetics, ...

Passed to ggplot2::discrete_scale().

Format

An object of class ScaleParty (inherits from ScaleDiscrete, Scale, ggproto, gg) of length 2.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
party_colour(c(NA, "Liberal Party of Canada", "Conservative Party of Canada"))

library(ggplot2)

cols_df <- tibble::tibble(
  col = canadian_party_colours(),
  party = names(col),
  n = seq_along(col),
  x = n %/% 4,
  y = n %% 4
)

ggplot(cols_df, aes(x, y, col = party))  +
  geom_point(size = 10) +
  scale_colour_party()

ggplot(cols_df, aes(x, y, fill = party))  +
  geom_tile() +
  scale_fill_party()

paleolimbot/electionca documentation built on Jan. 23, 2020, 4:36 p.m.