R/title.R

Defines functions title.gsplot title

Documented in title

#' gsplot title
#'
#' Adds a title to the plot.  See \code{\link[graphics]{title}} for more details.
#' 
#' @details Additional graphical parameter inputs:
#' \itemize{
#'  \item{\code{main}} {character string that goes above the plot}
#'  \item{\code{sub}} {character string that goes below the plot}
#'  \item{\code{col.main, col.sub}} {color for the main title and subtitle, respectively}
#'  \item{\code{font.main, font.sub}} {numeric value specifying the font style (1=normal, 2=bold, 3=italic, 4=bold and italic)}
#'  \item{\code{cex.main, cex.sub}} {numeric value specifying the size of the main title and subtitle}
#' }
#' 
#' @param object gsplot object
#' @param \dots Further graphical parameters may also be supplied as arguments. See 'Details'.
#'  
#' @seealso \code{\link[graphics]{title}}
#' @export
#' @examples
#' gs <- gsplot() %>%
#'       points(y=1, x=2, col="blue", pch=18, legend.name="Points", xlab="Stuff") %>%
#'       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!") %>%
#'       title(main="Great Graph", col.main="grey", font.main=2, cex.main=2)
#' gs
#' gs <- gsplot() %>%
#'       points(y=1, x=2) %>%
#'       title(main="Great Graph")
#' gs
title <- function(object, ...) {
  override("graphics", "title", object, ...)
}


title.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
  to.gsplot <- set_args("title", ..., custom.config = object[["global"]][["config"]][["config.file"]], package = "graphics")
  
  object$global$title <- append_replace(object$global$title, to.gsplot)
  return(object)
}
USGS-R/gsplot documentation built on April 17, 2023, 8:45 p.m.