R/arrows.R

Defines functions arrows.gsplot arrows

Documented in arrows

#' gsplot arrows
#'
#' Creates an arrow pointing at a specified plot location. See \code{\link[graphics]{arrows}} for more details.
#' 
#' @param object gsplot object
#' @param \dots Further graphical parameters may also be supplied as arguments. See 'Details'.
#' 
#' @details Often used with \code{\link{text}} to label a feature on the plot. Additional graphical parameter inputs:
#' \itemize{
#'  \item{\code{x0, y0}} {position of the arrow tail}
#'  \item{\code{x, y}} {position of the arrow head}
#'  \item{\code{col, lty, lwd}} {parameters describing the color, type, and width of the arrow, respectively}
#'  \item{\code{legend.name}} {name that appears in the legend, see \code{\link{legend}} for more legend parameters}
#' }
#' 
#' @export
#' @seealso \code{\link[graphics]{arrows}}
#' @examples
#' gs <- gsplot() %>%
#'    points( y=c(3,1,2), x=1:3, xlim=c(0,NA),ylim=c(0,NA),
#'             col="blue", pch=18, legend.name="Points", xlab="Index") %>%
#'    lines(c(3,4,3), c(2,4,6), legend.name="Lines", ylab="Data") %>%
#'    abline(b=1, a=0, legend.name="1:1") %>%
#'    legend(location="topleft",title="Awesome!") %>%
#'    grid() %>%
#'    error_bar(x=1:3, y=c(3,1,2), offset.up=c(0.5,0.25,1), offset.down=0.1) %>%
#'    error_bar(x=1:3, y=c(3,1,2), offset.left=.2, offset.right=.2, col="red",lwd=3) %>%
#'    arrows(x0=0.75, y0=2, x1=1, y1=2.8, lwd=2) %>%
#'    title("Graphing Fun") %>%
#'    text(.75,1.75,labels="Weird data")
#' gs
arrows <- function(object, ...) {
  override("graphics", "arrows", object, ...)
}


arrows.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
  fun.name <- 'arrows'
  object <- gather_function_info(object, fun.name, ..., legend.name=legend.name, side=side)
  return(object)
}
USGS-R/gsplot documentation built on April 17, 2023, 8:45 p.m.