Skip to content

Commit d5c87c2

Browse files
author
Jordan S Read
committed
adding view-level pars #247
1 parent 0055534 commit d5c87c2

File tree

20 files changed

+96
-20
lines changed

20 files changed

+96
-20
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: gsplot
22
Type: Package
33
Title: Geological Survey Plotting
4-
Version: 0.3.2
5-
Date: 2015-09-12
4+
Version: 0.4.0
5+
Date: 2015-09-16
66
Authors@R: c( person("Jordan", "Read", role = "aut",
77
email = "[email protected]"),
88
person("Laura", "DeCicco", role = c("aut","cre"),

R/abline.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ abline <- function(object, ...) {
2828

2929

3030
abline.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
31-
set_window_args(object, fun.name='abline', ..., legend.name=legend.name, side=side)
31+
set_window_args(object, fun.name='abline', ..., legend.name=legend.name, side=side, def.funs=graphics::abline)
3232
}

R/arrows.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ arrows <- function(object, ...) {
3333

3434

3535
arrows.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
36-
set_window_args(object, fun.name='arrows', ..., legend.name=legend.name, side=side)
36+
set_window_args(object, fun.name='arrows', ..., legend.name=legend.name, side=side, def.funs=graphics::arrows)
3737
}

R/calc_views.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ group_views <- function(gsplot){
4848
if (!is.null(view.1) && !is.null(view.2) && any(view.2==view.1)){
4949
v.i = view.2[which(view.2 %in% view.1)]
5050
views[[v.i]] <- append(views[[v.i]], to_draw)
51+
views[[v.i]][['window']][['par']] <- append_replace(views[[v.i]][['window']][['par']], tail.gs[['gs.config']][['par']])
5152
} else{
52-
views <- append(views, list(view = append(to_draw, list(window=list(side=add_sides)))))
53+
views <- append(views, list(view = append(to_draw, list(window=list(side=add_sides,par=tail.gs[['gs.config']][['par']])))))
5354
}
5455
} else {
5556
# // if field isn't associated with a side(s), it is moved up to top level (e.g., legend)
@@ -61,6 +62,13 @@ group_views <- function(gsplot){
6162
return(append(views, non.views))
6263
}
6364

65+
append_replace <- function(old.list, new.list){
66+
out.list <- old.list
67+
out.list[names(old.list) %in% names(new.list)] <- new.list[names(out.list[names(old.list) %in% names(new.list)])]
68+
new.list[names(new.list) %in% names(old.list)] <- NULL
69+
out.list <- append(out.list, new.list)
70+
return(out.list)
71+
}
6472
set_sides <- function(sides){
6573
if (length(sides)==1){
6674
if(sides %% 2 == 0)

R/callouts.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ callouts <- function(object, ...) {
2929

3030
callouts.gsplot <- function(object, ..., side=c(1,2)){
3131

32-
set_window_args(object, fun.name='callouts', ..., legend.name=NULL, side=side, package='gsplot')
32+
set_window_args(object, fun.name='callouts', ..., legend.name=NULL, side=side, package='gsplot', def.funs=c(graphics::arrows,callouts.default))
3333
}
3434
#' Default for adding callouts to a plot.
3535
#'

R/grid.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ grid <- function(object, ...) {
2121

2222

2323
grid.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
24-
set_window_args(object, fun.name='grid', ..., legend.name=legend.name, side=side)
24+
set_window_args(object, fun.name='grid', ..., legend.name=legend.name, side=side, def.funs = graphics::grid)
2525
}

R/lines.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ lines <- function(object, ...) {
4343

4444

4545
lines.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
46-
set_window_args(object, fun.name='lines', ..., legend.name=legend.name, side=side)
46+
set_window_args(object, fun.name='lines', ..., legend.name=legend.name, side=side, def.funs=c(graphics::plot.xy, graphics::lines.default))
4747
}

R/mtext.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ mtext <- function(object, ...) {
2929

3030

3131
mtext.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
32-
set_window_args(object, fun.name='mtext', ..., legend.name=legend.name, side=side)
32+
set_window_args(object, fun.name='mtext', ..., legend.name=legend.name, side=side, def.funs=graphics::mtext)
3333
}

R/par_arguments.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
par_arguments <- function(arguments, def.funs){
2+
3+
args = arguments[!names(arguments) %in% names(formal_arguments(arguments, def.funs)) & names(arguments) %in% names(par(no.readonly=T))]
4+
if (length(args) > 0)
5+
return(args)
6+
else
7+
NULL
8+
}
9+
10+
formal_arguments <- function(arguments, def.funs){
11+
if (length(def.funs) > 1)
12+
formal_names <- unique(unlist(lapply(def.funs, function(x)names(formals(x)))))
13+
else
14+
formal_names <- names(formals(def.funs))
15+
args = arguments[names(arguments) %in% formal_names]
16+
if (length(args) > 0)
17+
return(args)
18+
else
19+
NULL
20+
}
21+
22+
window_arguments <- function(arguments, def.funs){
23+
args = arguments[!names(arguments) %in% names(formal_arguments(arguments, def.funs)) & !names(arguments) %in% names(par(no.readonly=T))]
24+
if (length(args) > 0)
25+
return(args)
26+
else
27+
NULL
28+
}

R/points.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ points <- function(object, ...) {
4646
}
4747

4848
points.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
49-
set_window_args(object, fun.name='points', ..., legend.name=legend.name, side=side)
49+
set_window_args(object, fun.name='points', ..., legend.name=legend.name, side=side, def.funs = c(graphics::plot.xy, graphics::points.default))
5050
}

0 commit comments

Comments
 (0)