Skip to content

Commit c801419

Browse files
author
Lindsay Carr
authored
Merge pull request #355 from jread-usgs/master
code for several issues
2 parents 9ff7f36 + 9daebee commit c801419

File tree

9 files changed

+27
-51
lines changed

9 files changed

+27
-51
lines changed

R/bgCol.R

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ bgCol <- function(object, ...) {
3636

3737
bgCol.gsplot <- function(object, ...){
3838

39-
4039
to.gsplot <- filter_arguments(fun.name = "bgCol", ...)$call.args
41-
object <- append(object, to.gsplot)
42-
class(object) <- 'gsplot'
40+
object$global$bgCol <- append_replace(object$global$bgCol, to.gsplot[[1]])
4341
return(object)
4442

4543
}
@@ -49,10 +47,9 @@ bgCol.gsplot <- function(object, ...){
4947
#' @param col color code or name,
5048
#' see \code{\link[grDevices]{colors}}, \code{\link[grDevices]{palette}}.
5149
#' Here NULL means color 0.
52-
#' @param \dots additional arguments passed to \code{\link[graphics]{rect}}
5350
#' @export
5451
#' @keywords internal
55-
bgCol.default <- function(col,...){
52+
bgCol.default <- function(col=NULL){
5653

5754
if(par()$xlog){
5855
x1 <- 10^(par("usr")[1])
@@ -70,7 +67,7 @@ bgCol.default <- function(col,...){
7067
y2 <- par("usr")[4]
7168
}
7269

73-
rect(x1,y1,x2,y2,col = col, border = NA, ...)
70+
rect(x1,y1,x2,y2,col = col, border = NA)
7471

7572
}
7673

R/gather_function_info.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#' @return a code{gsplot} object
2020
#' @keywords internal
2121
gather_function_info <- function(object, fun.name, ..., legend.name, side){
22-
arguments <- filter_arguments(fun.name, ...)
22+
arguments <- filter_arguments(fun.name, ..., side=side)
2323

2424
call.args <- arguments$call.args
2525
option.args <- arguments$option.args

R/print.R

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ print.gsplot <- function(x, ...){
4343

4444
par(x$global$par)
4545

46-
bg.arg <- views$bgCol
47-
title.arg <- views$title
48-
46+
bg.arg <- views$global$bgCol
47+
title.arg <- views$global$title
48+
bgCol(bg.arg)
49+
title(title.arg)
4950
view.info <- view_info(views)
5051
side.names <- side_names(views)
5152

@@ -73,13 +74,9 @@ print.gsplot <- function(x, ...){
7374
if(any(names(views[[view.name]]) %in% 'grid')){
7475
draw_custom_grid(views,view.name)
7576
}
77+
7678
print.view(views[[view.name]])
77-
# -- initial view --
78-
if(view.name == view_names(views)[1]){
79-
if (!is.null(bg.arg))
80-
bgCol(bg.arg)
81-
title(title.arg)
82-
}
79+
8380
par(new=TRUE)
8481
}
8582

R/title.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ title <- function(object, ...) {
3535
title.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
3636
to.gsplot <- set_args("title", ..., package = "graphics")
3737

38-
to.gsplot <- list("title"=to.gsplot)
39-
40-
object <- append(object, to.gsplot)
41-
class(object) <- 'gsplot'
38+
object$global$title <- append_replace(object$global$title, to.gsplot)
4239
return(object)
43-
# set_window_args(object, fun.name='title', ..., legend.name=legend.name, side=side, def.funs=graphics::title)
4440
}

inst/doc/gsplotIntro.html

Lines changed: 11 additions & 25 deletions
Large diffs are not rendered by default.

man/bgCol.default.Rd

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

tests/testthat/test-mtext.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ test_that("mtext on correct side", {
1010
expect_true(4 %in% gsplot:::as.side(names(gs[i])))
1111
warning('skipping axes test in mtext. not sure why this was here')
1212
#expect_false(gs$side.4$axes)
13+
14+
expect_equal(gs$view.1.4$mtext$side, 4)
1315
})
1416

1517

tests/testthat/test-title.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test_that("testing content of gsplot list for title", {
1111
lines(20:30,20:30, side=c(3,4)) %>%
1212
title("Great Graph")
1313

14-
expect_true(any(names(gs) %in% "title"))
14+
expect_true(any(names(gs$global) %in% "title"))
1515

1616
})
1717

tests/testthat/tests-bgCol.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test_that("testing content of gsplot list for bgCol", {
1111
lines(20:30,20:30, side=c(3,4)) %>%
1212
bgCol(col="coral2")
1313

14-
expect_true(any(names(gs) %in% "bgCol"))
14+
expect_true(any(names(gs$global) %in% "bgCol"))
1515

1616
})
1717

0 commit comments

Comments
 (0)