Skip to content

Commit

Permalink
fixed annotations & rebuilt repo
Browse files Browse the repository at this point in the history
  • Loading branch information
B.Anderson committed Jul 8, 2020
1 parent 5d050bf commit b97eb0e
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 17 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(addVeDayDateTime)
export(addWeekendRectsDate)
export(addWeekendRectsDateTime)
export(addWhitsunDate)
export(addWhitsunDateTime)
export(alignDates)
export(cleanNZEmbEA)
export(cleanNZGridEA)
Expand Down
9 changes: 5 additions & 4 deletions R/addVeDayDate.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#' \code{addVeDayDate} adds extended weekend shading and label for VE day 2020 where x axis is a date. Should work in any time-zone
#'
#' @param p the plot to add them to
#' @param yLoc the reltative height of the label (so you can stagger them on a plot)
#' @param yMin the smallest y value
#' @param yMax the largest y value
#' @author Ben Anderson, \email{b.anderson@@soton.ac.uk} (original)
#' @export
#'
addVeDayDate <- function(p, yMin, yMax){
addVeDayDate <- function(p, yLoc, yMin, yMax){
p <- p + annotate("rect", xmin = as.Date("2020-05-08"),
xmax = as.Date("2020-05-11"), # 3 day weekend starting Friday (in UK)
xmax = as.Date("2020-05-09"), # 3 day weekend starting Friday (in UK)
ymin = yMin, ymax = yMax,
alpha = gcParams$weAlpha, fill = gcParams$weFill) +
alpha = 0.5, fill = gcParams$weFill) + #gcParams$weAlpha
annotate("text", x = as.Date("2020-05-08"),
y = yMax*gcParams$labelPos,
y = yLoc * yMax,
label = "VE Day 2020")
return(p)
}
8 changes: 5 additions & 3 deletions R/addVeDayDateTime.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#' \code{addVeDayDateTime} adds extended weekend shading and label for VE day 2020 where x axis is a dateTime. Should work in any time-zone.
#' \code{addVeDayDateTime} adds extended weekend shading and label for VE day 2020 where x axis is a dateTime.
#' Should work in any time-zone.
#'
#' @param p the plot to add them to
#' @param yLoc the relative location of the label (% of max plot height)
#' @param yMin the smallest y value
#' @param yMax the largest y value
#' @author Ben Anderson, \email{b.anderson@@soton.ac.uk} (original)
#' @export
#'
addVeDayDateTime <- function(p, yMin, yMax){
addVeDayDateTime <- function(p, yLoc, yMin, yMax){
p <- p + annotate("rect", xmin = lubridate::as_datetime("2020-05-08 00:00:00"),
xmax = lubridate::as_datetime("2020-05-10 23:59:59"), # 3 day weekend starting Friday (in the UK)
ymin = yMin, ymax = yMax,
alpha = gcParams$weAlpha, fill = gcParams$weFill) + # VE Day
annotate("text", x = lubridate::as_datetime("2020-05-08 12:00:00"),
y = yMax*gcParams$labelPos,
y = yLoc * yMax,
label = "VE Day 2020")
return(p)
}
11 changes: 6 additions & 5 deletions R/addWhitsunDate.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#' \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 yLoc the reltative height of the label (so you can stagger them on a plot)
#' @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"),
addWhitsunDate <- function(p, yLoc, yMin, yMax){
p <- p + annotate("rect", xmin = as.Date("2020-05-25"),
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,
alpha = 0.5, fill = gcParams$weFill) +
annotate("text", x = as.Date("2020-05-25"),
y = yLoc * yMax,
label = "Whitsun 2020")
return(p)
}
20 changes: 20 additions & 0 deletions R/addWhitsunDateTime.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#' \code{addWhitsunDate} adds extended weekend shading and label for UK Whit Sunday (late spring bank holiday)
#' where x axis is a dateTime. Should work in any time-zone
#'
#' @param p the plot to add them to
#' @param yLoc the reltative height of the label (so you can stagger them on a plot)
#' @param yMin the smallest y value
#' @param yMax the largest y value
#' @author Ben Anderson, \email{b.anderson@@soton.ac.uk} (original)
#' @export
#'
addWhitsunDateTime <- function(p, yLoc, yMin, yMax){
p <- p + annotate("rect", xmin = as.Date("2020-05-25 00:00:00"),
xmax = as.Date("2020-05-25 23:59:59"), # 3 day weekend starting Saturday (in UK)
ymin = yMin, ymax = yMax,
alpha = 0.5, fill = gcParams$weFill) +
annotate("text", x = as.Date("2020-05-25"),
y = yLoc * yMax,
label = "Whitsun 2020")
return(p)
}
4 changes: 3 additions & 1 deletion man/addVeDayDate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions man/addVeDayDateTime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/addWhitsunDate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions man/addWhitsunDateTime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b97eb0e

Please sign in to comment.