Skip to content

Commit 64bd86c

Browse files
Revert stat_function -> geom_function change, keep override.aes fix
As requested: stat_function isn't deprecated, and switching to geom_function could break backwards compatibility for users passing geom via overlay_function(...). Only the size -> linewidth fix in override.aes remains.
1 parent eea030b commit 64bd86c

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

R/bayesplot-helpers.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#' [ggplot2::element_line()].
2222
#'
2323
#' For `overlay_function`, `...` is passed to
24-
#' [ggplot2::geom_function()].
24+
#' [ggplot2::stat_function()].
2525
#'
2626
#' @return
2727
#' A **ggplot2** layer or [ggplot2::theme()] object that can be
@@ -91,7 +91,7 @@
9191
#' }
9292
#'
9393
#' \subsection{Superimpose a function on an existing plot}{
94-
#' * `overlay_function()` is a simple wrapper for [ggplot2::geom_function()] but
94+
#' * `overlay_function()` is a simple wrapper for [ggplot2::stat_function()] but
9595
#' with the `inherit.aes` argument fixed to `FALSE`. Fixing `inherit.aes=FALSE`
9696
#' will avoid potential errors due to the [ggplot2::aes()]thetic mapping used by
9797
#' certain **bayesplot** plotting functions.
@@ -476,7 +476,7 @@ grid_lines_y <- function(color = "gray50", linewidth = 0.2) {
476476
#' @rdname bayesplot-helpers
477477
#' @export
478478
overlay_function <- function(...) {
479-
geom_function(..., inherit.aes = FALSE)
479+
stat_function(..., inherit.aes = FALSE)
480480
}
481481

482482

man/bayesplot-helpers.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-convenience-functions.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ test_that("yaxis_ticks returns correct theme object", {
180180

181181
# overlay functions -------------------------------------------------------
182182
test_that("overlay_function returns the correct object", {
183+
expect_error(overlay_function(), 'argument "fun" is missing')
183184
a <- overlay_function(fun = "dnorm")
184-
b <- geom_function(fun = "dnorm", inherit.aes = FALSE)
185+
b <- stat_function(fun = "dnorm", inherit.aes = FALSE)
185186
a$constructor <- b$constructor <- NULL
186187
expect_equal(a, b, ignore_function_env = TRUE)
187188
})

0 commit comments

Comments
 (0)