Skip to content

Commit

Permalink
remove use of par and put into plot
Browse files Browse the repository at this point in the history
  • Loading branch information
njtierney committed Sep 5, 2022
1 parent 8f70c20 commit 6aadc86
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
15 changes: 10 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ remotes::install_github("greta-dev/greta.gp")

## Example usage

```{r par, echo = FALSE}
par(las = 1, fg = grey(0.7), mar = c(2, 2, 1, 1))
```

```{r simulate, message = FALSE}
# simulate data
x <- runif(20, 0, 10)
Expand Down Expand Up @@ -85,7 +81,16 @@ draws <- mcmc(m, n_samples = 250)

```{r plotting, fig.width = 10, fig.height = 6, dpi = 200}
# plot 200 posterior samples
plot(y ~ x, pch = 16, col = grey(0.4), xlim = c(0, 10), ylim = c(-2.5, 2.5))
# plot 200 posterior samples
plot(
y ~ x,
pch = 16,
col = grey(0.4),
xlim = c(0, 10),
ylim = c(-2.5, 2.5),
las = 1,
fg = grey(0.7),
)
for (i in 1:200) {
lines(draws[[1]][i, ] ~ x_plot,
lwd = 2,
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ draws <- mcmc(m, n_samples = 250)

``` r
# plot 200 posterior samples
plot(y ~ x, pch = 16, col = grey(0.4), xlim = c(0, 10), ylim = c(-2.5, 2.5))
# plot 200 posterior samples
plot(
y ~ x,
pch = 16,
col = grey(0.4),
xlim = c(0, 10),
ylim = c(-2.5, 2.5),
las = 1,
fg = grey(0.7),
)
for (i in 1:200) {
lines(draws[[1]][i, ] ~ x_plot,
lwd = 2,
Expand Down
Binary file modified man/figures/README-plotting-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 15 additions & 8 deletions vignettes/getting-started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ library(greta.gp)

#### Example

```{r par, echo = FALSE}
par(las = 1, fg = grey(0.7), mar = c(2, 2, 1, 1))
```

```{r simulate, message = FALSE}
# simulate data
x <- runif(20, 0, 10)
Expand Down Expand Up @@ -67,10 +63,21 @@ draws <- mcmc(m)

```{r plotting, fig.width = 10, fig.height = 6, dpi = 200}
# plot 200 posterior samples
plot(y ~ x, pch = 16, col = grey(0.4), xlim = c(0, 10), ylim = c(-2.5, 2.5))
plot(
y ~ x,
pch = 16,
col = grey(0.4),
xlim = c(0, 10),
ylim = c(-2.5, 2.5),
las = 1,
fg = grey(0.7),
)
for (i in 1:200) {
lines(draws[[1]][i, ] ~ x_plot,
lwd = 2,
col = rgb(0.7, 0.1, 0.4, 0.1))
lines(
draws[[1]][i, ] ~ x_plot,
lwd = 2,
col = rgb(0.7, 0.1, 0.4, 0.1)
)
}
```

0 comments on commit 6aadc86

Please sign in to comment.