-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathgrid.R
More file actions
31 lines (28 loc) · 1.02 KB
/
grid.R
File metadata and controls
31 lines (28 loc) · 1.02 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
#' gsplot grid
#'
#' Adds grid lines to the plot background. See \code{\link[graphics]{grid}} for more details.
#'
#' @param object gsplot object
#' @param \dots Further graphical parameters may also be supplied as arguments
#'
#' @export
#' @examples
#' gs <- gsplot()
#' gsNew <- points(gs, y=1, x=2, xlim=c(0,NA),ylim=c(0,NA),
#' col="blue", pch=18, legend.name="Points")
#' gsNew <- lines(gsNew, c(3,4,3), c(2,4,6), legend.name="Lines")
#' gsNew <- grid(gsNew)
#' gsNew <- abline(gsNew, b=1, a=0, legend.name="1:1")
#' gsNew <- legend(gsNew, location="topleft",title="Awesome!")
#' gsNew
grid <- function(object, ...) {
override("graphics", "grid", object, ...)
}
grid.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
fun.name <- "grid"
arguments <- list(...)
to.gsplot <- list(list(arguments = do.call(set_args, c(fun.name, arguments)),
gs.config=list(legend.name = legend.name, side = side))) %>%
setNames(fun.name)
return(gsplot(append(object, to.gsplot)))
}