Skip to content

Commit

Permalink
Create scale_gov function (issue ukgovdatascience#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkerlogue committed Jan 26, 2019
1 parent 5d09353 commit 1b395c1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions R/scale_gov.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#' @title Discrete colour scales using the gov_cols palette
#'
#' @description \code{scale_gov} provides a means to easily use the \code{
#' \linl{gov_cols}} palette in charts
#'
#' @param type sets whether the scale applies to (line) \code{colour}, the
#' \code{fill} colour, or \code{both}.
#'
#' @export

scale_gov <- function(type = "fill", ...) {

type = match.arg(type, c("colour", "fill"))

cols <- unname(gov_cols)

if (type == "fill") {
s <- ggplot2::scale_fill_manual(values = cols)
} else if (type == "colour") {
s <- ggplot2::scale_colour_manual(values = cols)
}

return(s)

}

0 comments on commit 1b395c1

Please sign in to comment.