Skip to content

Commit c51fa48

Browse files
authored
Improve stat_function documentation regarding xlim argument (#4871)
1 parent 775f1b4 commit c51fa48

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ggplot2 (development version)
22

3+
* Improve `stat_function` documentation regarding `xlim` argument. (@92amartins, #4474)
4+
35
* `qplot()` is now formally deprecated (@yutannihilation, #3956).
46

57
* Use `rlang::hash()` instead of `digest::digest()`. This update may lead to

R/geom-function.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
#'
5252
#' base + geom_function(fun = f)
5353
#'
54+
#' # Using xlim to restrict the range of function
55+
#' ggplot(data.frame(x = rnorm(100)), aes(x)) +
56+
#' geom_density() +
57+
#' geom_function(fun = dnorm, colour = "red", xlim=c(-1, 1))
58+
#'
59+
#' # Using xlim to widen the range of function
60+
#' ggplot(data.frame(x = rnorm(100)), aes(x)) +
61+
#' geom_density() +
62+
#' geom_function(fun = dnorm, colour = "red", xlim=c(-7, 7))
63+
#'
5464
#' @export
5565
geom_function <- function(mapping = NULL, data = NULL, stat = "function",
5666
position = "identity", ..., na.rm = FALSE,

R/stat-function.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' be vectorised.
55
#' @param n Number of points to interpolate along the x axis.
66
#' @param args List of additional arguments passed on to the function defined by `fun`.
7-
#' @param xlim Optionally, restrict the range of the function to this range.
7+
#' @param xlim Optionally, specify the range of the function.
88
#' @section Computed variables:
99
#' `stat_function()` computes the following variables:
1010
#' \describe{

man/geom_function.Rd

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

man/geom_map.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)