Skip to content

Commit a27a00e

Browse files
committed
Merge pull request #289 from jread-usgs/rename_view
Rename view
2 parents 6a1d2e2 + 816af24 commit a27a00e

File tree

13 files changed

+32
-25
lines changed

13 files changed

+32
-25
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.4.4
5-
Date: 2015-09-16
4+
Version: 0.5.0
5+
Date: 2015-12-05
66
Authors@R: c( person("Jordan", "Read", role = "aut",
77
email = "[email protected]"),
88
person("Laura", "DeCicco", role = c("aut","cre"),

R/access-gsplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ logged.gsplot <- function(object, side=NULL){
8282
#' @return data frame with one row per view. Each view has an x side, y side, the log command, and the view index.
8383
#' @export
8484
view_info <- function(object){
85-
j <- which(names(object) %in% 'view')
85+
j <- grep('view.', names(object))
8686
viewSides <- sapply(j, function(x) object[[x]][['window']][['side']])
8787
viewLogs <- sapply(j, function(x) object[[x]][['window']][['log']])
8888
viewInfo <- data.frame(t(rbind(viewSides, viewLogs, j)), stringsAsFactors = FALSE)

R/calc_views.R

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ calc_views <- function(gsplot){
2525
}
2626

2727
views <- function(gsplot){
28-
gsplot[names(gsplot) %in% 'view']
28+
gsplot[grep('view.', names(gsplot))]
2929
}
3030

3131
non_views <- function(gsplot){
32-
gsplot[!names(gsplot) %in% 'view']
32+
non.views <- gsplot
33+
non.views[grep('view.', names(non.views))] <- NULL
34+
return(non.views)
3335
}
3436

3537
group_views <- function(gsplot){
@@ -50,7 +52,9 @@ group_views <- function(gsplot){
5052
views[[v.i]] <- append(views[[v.i]], to_draw)
5153
views[[v.i]][['window']][['par']] <- append_replace(views[[v.i]][['window']][['par']], tail.gs[['gs.config']][['par']])
5254
} else{
53-
views <- append(views, list(view = append(to_draw, list(window=list(side=add_sides,par=tail.gs[['gs.config']][['par']])))))
55+
new.view <- list(append(to_draw, list(window=list(side=add_sides,par=tail.gs[['gs.config']][['par']])))) %>%
56+
setNames(sprintf('view.%s.%s',add_sides[1],add_sides[2]))
57+
views <- append(views, new.view)
5458
}
5559
} else {
5660
# // if field isn't associated with a side(s), it is moved up to top level (e.g., legend)
@@ -88,7 +92,7 @@ which_reals <- function(values, na.value){
8892

8993
}
9094
set_view_window <- function(views, param, na.value=NA, remove=TRUE, ignore=NULL){
91-
view_i <- which(names(views) %in% "view")
95+
view_i <- grep('view.', names(views))
9296
for (i in view_i){
9397
values <- lapply(views[[i]][!names(views[[i]]) %in% ignore], function(x) strip_pts(x, param))
9498
val.i <- which_reals(values, na.value)
@@ -194,15 +198,15 @@ views_with_side <- function(views, side){
194198
if(length(side) > 1)
195199
stop('side can only be length of 1')
196200
with.side = lapply(views, function(x) any(x[['window']][['side']] %in% side))
197-
view.match = unname(unlist(with.side[names(with.side) == 'view']))
201+
view.match = unname(unlist(with.side[grep('view.', names(views))]))
198202
if (is.null(view.match) || !any(view.match))
199203
return(NULL)
200204
else
201205
return(which(view.match))
202206
}
203207

204208
get_view_side <- function(views, view_i, param){
205-
i = which(names(views) %in% 'view')[view_i]
209+
i = grep('view.', names(views))[view_i]
206210
sides <- views[[i]][['window']][['side']]
207211
if (param=='y')
208212
return(sides[which(sides %% 2 == 0)])
@@ -212,9 +216,9 @@ get_view_side <- function(views, view_i, param){
212216
stop('view side undefined for ',param)
213217
}
214218

215-
summarize_args <- function(views, param, na.value,ignore='gs.config'){
219+
summarize_args <- function(views, param, na.value, ignore='gs.config'){
216220

217-
view_i <- which(names(views) %in% "view")
221+
view_i <- grep('view.', names(views))
218222
values <- list()
219223
for (i in view_i){
220224
x <- views[[i]][!names(views[[i]]) %in% ignore]
@@ -256,7 +260,7 @@ set_window <- function(list){
256260
listOut <- list
257261
pars <- list[['par']]
258262

259-
for(j in which(names(list) == "view")){
263+
for(j in grep('view.', names(list))){
260264

261265
window <- list[[j]][['window']]
262266
plots <- list[[j]]

R/callouts.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ callouts.gsplot <- function(object, ..., side=c(1,2)){
3838
#' @param labels text to be added to callout
3939
#' @param length relative (percentage of window width and height) distance for callout
4040
#' @param angle callout line angle
41+
#' @param cex passed to text for font size formatting
4142
#'
4243
#' @rdname callouts
4344
#' @export
44-
callouts.default <- function(x, y=NULL, labels=NA, length=0.1, angle='auto', cex=1, ...){
45+
callouts.default <- function(x, y=NULL, labels=NA, length=0.1, angle='auto', cex=par()$cex, ...){
4546

4647
if (is.null(y)) {
4748
warning("y=NULL not currently supported in callouts.default")

R/points.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#'
2828
#' gs <- gsplot() %>%
2929
#' points(x=1:5, y=1:5, xlim=c(0,10), ylim=c(0,10),
30-
#' callouts=list(labels=c(rep(NA, 4), "oh")),
31-
#' error_bar=list(y.high=1))
30+
#' callouts(labels=c(rep(NA, 4), "oh")),
31+
#' error_bar(y.high=1))
3232
#' gs
3333
#'
3434
#' gs2 <- gsplot() %>%
28.3 KB
Loading
22.9 KB
Loading
34.9 KB
Loading

man/callouts.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/points.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)