Skip to content

Commit

Permalink
RAther than dev.off, re-define par.
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:ldecicco-USGS/gsplot into configBranch

# Conflicts:
#	inst/doc/gsplotIntro.html
  • Loading branch information
ldecicco-USGS committed Aug 15, 2016
2 parents caa3abd + 754800d commit c287996
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 10 deletions.
11 changes: 6 additions & 5 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ loadConfig = function(filename) {
}

graphTemplate <- yaml.load_file(filename)
if(.Device != "null device"){
dev.off()

if(length(all.equal(gsconfig$orignial.par, par(no.readonly = TRUE))) > 1){
par(gsconfig$orignial.par)
}

gsconfig$options <- graphTemplate
}

Expand All @@ -47,8 +47,9 @@ load_temp_config = function(filename) {
gsconfig$orignial.par <- par(no.readonly = TRUE)

graphTemplate <- yaml.load_file(filename)
if(.Device != "null device"){
dev.off()

if(length(all.equal(gsconfig$orignial.par, par(no.readonly = TRUE))) > 1){
par(gsconfig$orignial.par)
}
gsconfig$temp.config <- graphTemplate
}
Expand Down
4 changes: 1 addition & 3 deletions R/gsplot-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ gsplot.default <- function(...,config.file=NA, theme=NA) {
}

if(length(all.equal(gsconfig$orignial.par, par(no.readonly = TRUE))) > 1){
if(.Device != "null device"){
dev.off()
}
par(gsconfig$orignial.par)
}

object <- add_new_par(object, 'global')
Expand Down
3 changes: 2 additions & 1 deletion R/legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ draw_legend <- function(gsplot) {
#set bg so that fill/border/etc args are correct, then evaluate any quoted list items
if (any(names(legend) %in% c("bg"))) {
par(bg=legend$bg)
} else {
par(bg = ifelse(par('bg') == "transparent", "#FFFFFF", par('bg')))
}
legend <- lapply(legend, function(x) {unname(sapply(x, function(x) {eval(x)}))})
# clean out arguments not allowed by legend
legend <- legend[na.omit(match(names(default.args), names(legend)))]
legend(legend)
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ myplot <- myplot %>% points(4,3,col="blue")
myplot
```

![](README_files/figure-markdown_github/unnamed-chunk-3-1.png)

<a name="legend"></a>

#### Automatic legend
Expand Down Expand Up @@ -130,6 +132,8 @@ myplot <- gsplot() %>%
myplot
```

![](README_files/figure-markdown_github/unnamed-chunk-5-1.png)

<a name="limits"></a>

#### Automatic limits
Expand All @@ -153,6 +157,8 @@ limitsplot <- gsplot() %>%
limitsplot
```

![](README_files/figure-markdown_github/unnamed-chunk-7-1.png)

<a name="error"></a>

#### Error bars
Expand All @@ -177,6 +183,8 @@ errorbarplot <- gsplot() %>%
errorbarplot
```

![](README_files/figure-markdown_github/unnamed-chunk-9-1.png)

<a name="callouts"></a>

#### Callouts
Expand All @@ -200,6 +208,8 @@ calloutsplot <- gsplot() %>%
calloutsplot
```

![](README_files/figure-markdown_github/unnamed-chunk-11-1.png)

<a name="reverse"></a>

#### Axis reversal
Expand All @@ -220,6 +230,8 @@ reverseplot <- gsplot() %>%
reverseplot
```

![](README_files/figure-markdown_github/unnamed-chunk-13-1.png)

<a name="embed"></a>

#### Embedded functions
Expand Down Expand Up @@ -248,6 +260,8 @@ embedplot <- gsplot() %>%
embedplot
```

![](README_files/figure-markdown_github/unnamed-chunk-15-1.png)

<a name="where"></a>

#### Change rendering order
Expand All @@ -262,6 +276,8 @@ renderorderplot <- gsplot() %>%
renderorderplot
```

![](README_files/figure-markdown_github/unnamed-chunk-16-1.png)

Say we have the plot above, but would like to add two red points.

``` r
Expand Down Expand Up @@ -297,6 +313,8 @@ gs
points(as.Date("2010-11-15"),2.5)
```

![](README_files/figure-markdown_github/unnamed-chunk-19-1.png)

Improved workflow examples
--------------------------

Expand All @@ -316,6 +334,8 @@ demoPlot <- gsplot() %>%
demoPlot
```

![](README_files/figure-markdown_github/unnamed-chunk-20-1.png)

``` r
gs <- gsplot() %>%
points(y=c(3,1,2,4,5), x=c(1:3,8,80),
Expand All @@ -329,6 +349,8 @@ gs <- gsplot() %>%
gs
```

![](README_files/figure-markdown_github/unnamed-chunk-21-1.png)

``` r
usrDef <- gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r') %>%
points(x=1, y=2, side=c(3,2), legend.name="Points 1", cex=3, xlab='cat') %>%
Expand All @@ -339,6 +361,8 @@ usrDef <- gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r') %>%
usrDef
```

![](README_files/figure-markdown_github/unnamed-chunk-22-1.png)

Disclaimer
----------

Expand Down
Binary file modified README_files/figure-markdown_github/unnamed-chunk-11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-13-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-15-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-16-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-19-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-20-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-21-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-22-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 55 additions & 1 deletion inst/doc/gsplotIntro.html

Large diffs are not rendered by default.

0 comments on commit c287996

Please sign in to comment.