Skip to content

Commit a89bfb4

Browse files
committed
Fixed #274
1 parent 591803b commit a89bfb4

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

R/grid.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#' gsNew <- points(gs, y=1, x=2, xlim=c(0,NA),ylim=c(0,NA),
1212
#' col="blue", pch=18, legend.name="Points")
1313
#' gsNew <- lines(gsNew, c(3,4,3), c(2,4,6), legend.name="Lines")
14-
#' gsNew <- grid(gsNew, legend.name="Grid")
14+
#' gsNew <- grid(gsNew)
1515
#' gsNew <- abline(gsNew, b=1, a=0, legend.name="1:1")
1616
#' gsNew <- legend(gsNew, location="topleft",title="Awesome!")
1717
#' gsNew
@@ -34,7 +34,13 @@
3434
#' points(x=seq.Date(as.Date("2000-01-01"),as.Date("2010-01-01"),length.out = 20),
3535
#' y=1:20,axes=FALSE) %>%
3636
#' grid()
37-
#'gs
37+
#' gs
38+
#'
39+
#' gs <- gsplot() %>%
40+
#' points(x=1:10, y=1:10) %>%
41+
#' grid(lty=3, col="gray") %>%
42+
#' axis(side=2, reverse=TRUE)
43+
#' gs
3844
grid <- function(object, ...) {
3945
override("graphics", "grid", object, ...)
4046
}
@@ -68,7 +74,7 @@ draw_custom_grid <- function(object, index){
6874
if(view.info$x.side.defined.by.user){
6975
axes.index <- i[definded.sides == view.info$x]
7076
x <- object[axes.index][['axis']][['arguments']][['at']]
71-
if(length(x.at) != 0){
77+
if(!is.null(x)){
7278
x.at <-x
7379
}
7480
}
@@ -84,7 +90,7 @@ draw_custom_grid <- function(object, index){
8490
if(view.info$y.side.defined.by.user){
8591
axes.index <- i[definded.sides == view.info$y]
8692
y <- object[axes.index][['axis']][['arguments']][['at']]
87-
if(length(y.at) != 0){
93+
if(!is.null(y)){
8894
y.at <- y
8995
}
9096
}

man/grid.Rd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ gs <- gsplot()
1919
gsNew <- points(gs, y=1, x=2, xlim=c(0,NA),ylim=c(0,NA),
2020
col="blue", pch=18, legend.name="Points")
2121
gsNew <- lines(gsNew, c(3,4,3), c(2,4,6), legend.name="Lines")
22-
gsNew <- grid(gsNew, legend.name="Grid")
22+
gsNew <- grid(gsNew)
2323
gsNew <- abline(gsNew, b=1, a=0, legend.name="1:1")
2424
gsNew <- legend(gsNew, location="topleft",title="Awesome!")
2525
gsNew
@@ -43,5 +43,11 @@ gs <- gsplot() \%>\%
4343
y=1:20,axes=FALSE) \%>\%
4444
grid()
4545
gs
46+
47+
gs <- gsplot() \%>\%
48+
points(x=1:10, y=1:10) \%>\%
49+
grid(lty=3, col="gray") \%>\%
50+
axis(side=2, reverse=TRUE)
51+
gs
4652
}
4753

0 commit comments

Comments
 (0)