Skip to content

Improve stat_function documentation regarding xlim argument #4871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggplot2 (development version)

* Improve `stat_function` documentation regarding `xlim` argument. (@92amartins, #4474)

* `qplot()` is now formally deprecated (@yutannihilation, #3956).

* Use `rlang::hash()` instead of `digest::digest()`. This update may lead to
Expand Down
10 changes: 10 additions & 0 deletions R/geom-function.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
#'
#' base + geom_function(fun = f)
#'
#' # Using xlim to restrict the range of function
#' ggplot(data.frame(x = rnorm(100)), aes(x)) +
#' geom_density() +
#' geom_function(fun = dnorm, colour = "red", xlim=c(-1, 1))
#'
#' # Using xlim to widen the range of function
#' ggplot(data.frame(x = rnorm(100)), aes(x)) +
#' geom_density() +
#' geom_function(fun = dnorm, colour = "red", xlim=c(-7, 7))
#'
#' @export
geom_function <- function(mapping = NULL, data = NULL, stat = "function",
position = "identity", ..., na.rm = FALSE,
Expand Down
2 changes: 1 addition & 1 deletion R/stat-function.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' be vectorised.
#' @param n Number of points to interpolate along the x axis.
#' @param args List of additional arguments passed on to the function defined by `fun`.
#' @param xlim Optionally, restrict the range of the function to this range.
#' @param xlim Optionally, specify the range of the function.
#' @section Computed variables:
#' `stat_function()` computes the following variables:
#' \describe{
Expand Down
12 changes: 11 additions & 1 deletion man/geom_function.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/geom_map.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.