3636# ' axis(side=c(2,4), labels=FALSE, n.minor=4)
3737# '
3838# ' gs2
39+ # '
40+ # ' gs <- points(gsplot(), c(0,3), c(2,4), callouts(labels=c('dogs','cats')))
41+ # ' gs
42+ # ' @importFrom lazyeval lazy_dots lazy_eval
3943# ' @export
4044points <- function (object , ... ) {
4145 override(" graphics" , " points" , object , ... )
4246}
4347
4448points.gsplot <- function (object , ... , legend.name = NULL , side = c(1 ,2 )){
4549 fun.name <- " points"
46- arguments <- list (... )
47-
48- if (is.null(names(arguments ))){
49- arguments_gsplot <- arguments
50- } else {
51- arguments_gsplot <- arguments [! names(arguments ) %in% c(" callouts" , " error_bar" )]
52- }
53-
54- to.gsplot <- list (list (arguments = do.call(set_args , c(fun.name , arguments_gsplot )),
55- gs.config = list (legend.name = legend.name , side = side ))) %> %
50+ dots = separate_args(... )
51+ args = dots $ args
52+ e.fun = dots $ e.fun
53+ arguments = set_args(fun.name , lazy_eval(args ))
54+ to.gsplot <- list (list (arguments = arguments , gs.config = list (legend.name = legend.name , side = side ))) %> %
5655 setNames(fun.name )
57-
58- if (all(names(to.gsplot $ points $ arguments ) != " formula" ) && is.null(to.gsplot $ points $ arguments [[' y' ]])){
59- to.gsplot $ points $ arguments $ y <- to.gsplot $ points $ arguments $ x
60- to.gsplot $ points $ arguments $ x <- seq(length(to.gsplot $ points $ arguments $ x ))
61- if (is.null(to.gsplot $ points $ arguments $ xlab )) to.gsplot $ points $ arguments $ xlab <- " Index"
62- }
63-
64- if (" callouts" %in% names(arguments )){
65- object <- callouts(object , x = to.gsplot $ points $ arguments $ x ,
66- y = to.gsplot $ points $ arguments $ y , arguments $ callouts )
67- }
68- if (" error_bar" %in% names(arguments )){
69- object <- error_bar(object , x = to.gsplot $ points $ arguments $ x ,
70- y = to.gsplot $ points $ arguments $ y , arguments $ error_bar )
56+
57+ object <- gsplot(append(object , to.gsplot )) # append initial call
58+ if (! is.null(e.fun )){
59+ embed.args = set_inherited_args(e.fun , arguments , dots $ e.args )
60+ object <- do.call(e.fun , append(list (object = object ), embed.args ))
7161 }
72-
73- return (gsplot(append(object , to.gsplot )))
62+ return (object )
7463}
0 commit comments