Skip to content

Commit a7c1138

Browse files
sinarueegerpaleolimbot
authored andcommitted
Document breaks/bins/binwidth parameters in stat/geom contour (#3423, fixes #2472)
* Added explicit bins, binwidth + breaks arguments and documented them in stat/geom contour
1 parent 0cdde1d commit a7c1138

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

R/geom-contour.r

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
#' @inheritParams layer
1313
#' @inheritParams geom_point
1414
#' @inheritParams geom_path
15-
#' @param bins,binwidth Calculate `breaks` using evenly-spaced values. Use `NULL`
16-
#' to use the default [pretty()] breaks.
17-
#' @param breaks A vector of breaks (overrides `bins` and `bindwidth`).
15+
#' @param bins Number of contour bins. Overridden by `binwidth`.
16+
#' @param binwidth The width of the contour bins. Overridden by `breaks`.
17+
#' @param breaks Numeric vector to set the contour breaks.
18+
#' Overrides `binwidth` and `bins`. By default, this is a vector of
19+
#' length ten with [pretty()] breaks.
1820
#' @seealso [geom_density_2d()]: 2d density contours
1921
#' @export
20-
#' @export
2122
#' @examples
2223
#' #' # Basic plot
2324
#' v <- ggplot(faithfuld, aes(waiting, eruptions, z = density))
@@ -49,12 +50,12 @@
4950
geom_contour <- function(mapping = NULL, data = NULL,
5051
stat = "contour", position = "identity",
5152
...,
52-
lineend = "butt",
53-
linejoin = "round",
54-
linemitre = 10,
5553
bins = NULL,
5654
binwidth = NULL,
5755
breaks = NULL,
56+
lineend = "butt",
57+
linejoin = "round",
58+
linemitre = 10,
5859
na.rm = FALSE,
5960
show.legend = NA,
6061
inherit.aes = TRUE) {
@@ -67,12 +68,12 @@ geom_contour <- function(mapping = NULL, data = NULL,
6768
show.legend = show.legend,
6869
inherit.aes = inherit.aes,
6970
params = list(
70-
lineend = lineend,
71-
linejoin = linejoin,
72-
linemitre = linemitre,
7371
bins = bins,
7472
binwidth = binwidth,
7573
breaks = breaks,
74+
lineend = lineend,
75+
linejoin = linejoin,
76+
linemitre = linemitre,
7677
na.rm = na.rm,
7778
...
7879
)

R/stat-contour.r

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ stat_contour <- function(mapping = NULL, data = NULL,
4141
stat_contour_filled <- function(mapping = NULL, data = NULL,
4242
geom = "polygon", position = "identity",
4343
...,
44+
bins = NULL,
45+
binwidth = NULL,
46+
breaks = NULL,
4447
na.rm = FALSE,
4548
show.legend = NA,
4649
inherit.aes = TRUE) {
@@ -53,6 +56,9 @@ stat_contour_filled <- function(mapping = NULL, data = NULL,
5356
show.legend = show.legend,
5457
inherit.aes = inherit.aes,
5558
params = list(
59+
bins = bins,
60+
binwidth = binwidth,
61+
breaks = breaks,
5662
na.rm = na.rm,
5763
...
5864
)

man/geom_contour.Rd

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

0 commit comments

Comments
 (0)