Colours for Canadian Political Parties

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

party_colour(c(NA, "Liberal Party of Canada", "Conservative Party of Canada"))
#> [1] "grey50" "#d71b1f" "#1d4881"
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()