R/helpers.R

## Taken from https://stackoverflow.com/questions/25401111/left-adjust-title-in-ggplot2-or-absolute-position-for-ggtitle
## ## Usage: plot is the ggplot object. Pieces is the list of items you want to left align.
## e.g. x <- left_align(figure, c("subtitle", "title", "caption"))
## then, to draw, use grid::grid.draw(x)

left_align <- function(plot, pieces){
    grob <- ggplotGrob(plot)
    n <- length(pieces)
    grob$layout$l[grob$layout$name %in% pieces] <- 2
    grob
}

get_colour <- function(col="blue", num=6, grid=bbc_colours){
    subset(grid, colour==col & shade==num)$code
}
bbcuffer/bbcfigr documentation built on May 17, 2019, 8:05 a.m.