-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtitle.R
More file actions
37 lines (35 loc) · 1.54 KB
/
title.R
File metadata and controls
37 lines (35 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#' 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'.
#'
#' @export
#' @examples
#' gs <- gsplot()
#' gsNew <- points(gs, y=1, x=2, col="blue", pch=18, legend.name="Points", xlab="Stuff")
#' gsNew <- lines(gsNew, c(3,4,3), c(2,4,6), legend.name="Lines", ylab="Data!")
#' gsNew <- abline(gsNew, b=1, a=0, legend.name="1:1")
#' gsNew <- legend(gsNew, location="topleft",title="Awesome!")
#' gsNew <- title(gsNew, main="Great Graph", col.main="grey", font.main=2, cex.main=2)
#' gsNew
title <- function(object, ...) {
override("graphics", "title", object, ...)
}
title.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
fun.name <- "title"
to.gsplot <- list(list(arguments = set_args(fun.name, ...),
gs.config=list(legend.name = legend.name, side = side))) %>%
setNames(fun.name)
return(gsplot(append(object, to.gsplot)))
}