Skip to content

Commit

Permalink
added function to put UK Whitsun publi choliday on a date plot
Browse files Browse the repository at this point in the history
  • Loading branch information
B.Anderson committed Jul 6, 2020
1 parent abb3b9f commit 0121498
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions R/addWhitsunDate.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#' \code{addWhitsunDate} adds extended weekend shading and label for UK Whit Sunday (late spring bank holiday) where x axis is a date. Should work in any time-zone
#'
#' @param p the plot to add them to
#' @param yMin the smallest y value
#' @param yMax the largest y value
#' @author Ben Anderson, \email{b.anderson@@soton.ac.uk} (original)
#' @export
#'
addWhitsunDate <- function(p, yMin, yMax){
p <- p + annotate("rect", xmin = as.Date("2020-05-23"),
xmax = as.Date("2020-05-26"), # 3 day weekend starting Saturday (in UK)
ymin = yMin, ymax = yMax,
alpha = gcParams$weAlpha, fill = gcParams$weFill) +
annotate("text", x = as.Date("2020-05-24"),
y = yMax*gcParams$labelPos,
label = "Whitsun 2020")
return(p)
}

0 comments on commit 0121498

Please sign in to comment.