Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
yjunechoe committed Oct 18, 2024
1 parent dbc9d1c commit 63366da
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ The error tells us that the geom is missing some missing aesthetics, so somethin
layer_before_geom(last_plot(), i = 2L, error = TRUE, verbose = TRUE)
```

Note that you can more conveniently call `last_layer_errorcontext()` to the same effect:

```{r boxplot-last_layer_errorcontext}
last_layer_errorcontext()
```

Thus, we need to ensure that `y` exists to satisfy both the stat and the geom, and that `label` exists after the statistical transformation step but before the geom sees the data. Crucially, we use the computed variable `ymax` to (re-)map to the `y` and `label` aesthetics.

```{r boxplot-anno-success}
Expand Down Expand Up @@ -206,6 +212,8 @@ Note that as of [{ggtrace} v0.7.1](https://github.com/yjunechoe/ggtrace/releases
It's interesting to note that this is also possible in "vanilla" ggplot. Following our earlier discussion of `after_stat()`:

```{r boxplot-remove-outliers-after-stat}
# NOTE: outdated solution - superseded by `outliers = FALSE` in ggplot >=v3.5.0
# Suppress warning from mapping to `outliers` aesthetic
update_geom_defaults("boxplot", list(outliers = NULL))
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ inspect this using `layer_before_geom()`, we find that the columns for
#> # ℹ 4 more variables: relvarwidth <dbl>, flipped_aes <lgl>, PANEL <fct>,
#> # group <int>

Note that you can more conveniently call `last_layer_errorcontext()` to
the same effect:

last_layer_errorcontext()
#> ✔ Executed `inspect_args(p, ggplot2:::Layer$compute_geom_1, layer_is(2L), error = TRUE, x = last_plot())$data`
#> # A tibble: 3 × 14
#> ymin lower middle upper ymax outliers notchupper notchlower x width
#> <dbl> <dbl> <dbl> <dbl> <dbl> <list> <dbl> <dbl> <dbl> <dbl>
#> 1 21.4 22.8 26 30.4 33.9 <dbl [0]> 29.6 22.4 1 0.75
#> 2 17.8 18.6 19.7 21 21.4 <dbl [0]> 21.1 18.3 2 0.75
#> 3 13.3 14.4 15.2 16.2 18.7 <dbl [3]> 16.0 14.4 3 0.75
#> # ℹ 4 more variables: relvarwidth <dbl>, flipped_aes <lgl>, PANEL <fct>,
#> # group <int>

Thus, we need to ensure that `y` exists to satisfy both the stat and the
geom, and that `label` exists after the statistical transformation step
but before the geom sees the data. Crucially, we use the computed
Expand Down Expand Up @@ -290,6 +304,8 @@ v0.7.1](https://github.com/yjunechoe/ggtrace/releases/tag/v0.7.1), all
It’s interesting to note that this is also possible in “vanilla” ggplot.
Following our earlier discussion of `after_stat()`:

# NOTE: outdated solution - superseded by `outliers = FALSE` in ggplot >=v3.5.0

# Suppress warning from mapping to `outliers` aesthetic
update_geom_defaults("boxplot", list(outliers = NULL))

Expand Down

0 comments on commit 63366da

Please sign in to comment.