R/scale_y_lat.R

Defines functions scale_y_lat

#' Set Latitude label
#'
#' @description Use Latitude ºS or Latitude ºN as Y axis label. For internal use in plot_telemetry()
#' @noRd
#' @keywords internal
#'
#' @details check https://stackoverflow.com/questions/33302424/format-latitude-and-longitude-axis-labels-in-ggplot

scale_y_lat <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(lapply(ybreaks, function(x) ifelse(x < 0, parse(text=paste0(x,"^o", "*S")), ifelse(x > 0, parse(text=paste0(x,"^o", "*N")),x))))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
}
machadoams/botomapr documentation built on Aug. 22, 2020, 9:44 p.m.