Skip to content

Commit 99c4ed0

Browse files
committed
Something's amiss with grid, I'm not sure what, but the readme example highlights it.
1 parent 3d87f1b commit 99c4ed0

6 files changed

Lines changed: 18 additions & 17 deletions

File tree

R/grid.R

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,21 @@
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)
1415
#' gsNew <- abline(gsNew, b=1, a=0, legend.name="1:1")
1516
#' gsNew <- legend(gsNew, location="topleft",title="Awesome!")
16-
#' gsNew <- grid(gsNew)
1717
#' gsNew
1818
grid <- function(object, ...) {
1919
override("graphics", "grid", object, ...)
2020
}
2121

2222

2323
grid.gsplot <- function(object, ..., legend.name=NULL, side=c(1,2)){
24-
current_list <- config("grid")
24+
fun.name <- "grid"
2525
arguments <- list(...)
2626

27-
indicesToAdd <- !(names(current_list) %in% names(arguments))
28-
arguments <- append(arguments, current_list[indicesToAdd])
29-
30-
object <- append(object, list(grid = list(arguments = arguments,
31-
gs.config=list(legend.name = legend.name,
32-
side = side))))
33-
return(gsplot(object))
27+
to.gsplot <- list(list(arguments = do.call(set_args, c(fun.name, arguments)),
28+
gs.config=list(legend.name = legend.name, side = side))) %>%
29+
setNames(fun.name)
30+
return(gsplot(append(object, to.gsplot)))
3431
}

README.Rmd

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ demoPlot <- gsplot() %>%
3636
col="blue", pch=18, legend.name="Points", xlab="Index") %>%
3737
lines(c(3,4,3), c(2,4,6), legend.name="Lines", ylab="Data") %>%
3838
abline(b=1, a=0, legend.name="1:1") %>%
39+
axis(side=c(3,4), labels=FALSE) %>%
3940
legend(location="topleft",title="Awesome!") %>%
40-
grid() %>%
41+
# grid() %>%
4142
error_bar(x=1:3, y=c(3,1,2), y.high=c(0.5,0.25,1), y.low=0.1) %>%
4243
error_bar(x=1:3, y=c(3,1,2), x.low=.2, x.high=.2, col="red",lwd=3) %>%
4344
callouts(x=1, y=2.8, lwd=2, angle=250, labels="Weird data") %>%
@@ -48,12 +49,13 @@ demoPlot
4849
```{r echo=TRUE, warning=FALSE, message=FALSE}
4950
library(gsplot)
5051
51-
demoPlot <- gsplot() %>%
52+
gs <- gsplot() %>%
5253
points(y=c(3,1,2,4,5), x=c(1:3,8,80), col="blue", pch=18, legend.name="Points") %>%
5354
lines(c(3,4,3), c(2,4,6), legend.name="Lines", ylab="logged y axis", xlab="logged x axis", log='xy') %>%
5455
callouts(x=8, y=4, lwd=2, angle=45, labels="Not sure about this one") %>%
55-
title("logged axes")
56-
demoPlot
56+
title("logged axes") %>%
57+
axis(side=c(1,2,3,4), labels=FALSE, n.minor=4)
58+
gs
5759
```
5860

5961
```{r echo=TRUE, warning=FALSE, message=FALSE}

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ demoPlot <- gsplot() %>%
3131
col="blue", pch=18, legend.name="Points", xlab="Index") %>%
3232
lines(c(3,4,3), c(2,4,6), legend.name="Lines", ylab="Data") %>%
3333
abline(b=1, a=0, legend.name="1:1") %>%
34+
axis(side=c(3,4), labels=FALSE) %>%
3435
legend(location="topleft",title="Awesome!") %>%
35-
grid() %>%
36+
# grid() %>%
3637
error_bar(x=1:3, y=c(3,1,2), y.high=c(0.5,0.25,1), y.low=0.1) %>%
3738
error_bar(x=1:3, y=c(3,1,2), x.low=.2, x.high=.2, col="red",lwd=3) %>%
3839
callouts(x=1, y=2.8, lwd=2, angle=250, labels="Weird data") %>%
@@ -45,12 +46,13 @@ demoPlot
4546
``` r
4647
library(gsplot)
4748

48-
demoPlot <- gsplot() %>%
49+
gs <- gsplot() %>%
4950
points(y=c(3,1,2,4,5), x=c(1:3,8,80), col="blue", pch=18, legend.name="Points") %>%
5051
lines(c(3,4,3), c(2,4,6), legend.name="Lines", ylab="logged y axis", xlab="logged x axis", log='xy') %>%
5152
callouts(x=8, y=4, lwd=2, angle=45, labels="Not sure about this one") %>%
52-
title("logged axes")
53-
demoPlot
53+
title("logged axes") %>%
54+
axis(side=c(1,2,3,4), labels=FALSE, n.minor=4)
55+
gs
5456
```
5557

5658
![](README_files/figure-markdown_github/unnamed-chunk-3-1.png)
-29.3 KB
Loading
-19.4 KB
Loading
-36.1 KB
Loading

0 commit comments

Comments
 (0)