Skip to content

Commit fa09e1a

Browse files
committed
Rename to stat_density_2d and geom_density_2d.
Fixes #1426
1 parent 630283b commit fa09e1a

File tree

12 files changed

+55
-40
lines changed

12 files changed

+55
-40
lines changed

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ export(geom_crossbar)
271271
export(geom_curve)
272272
export(geom_density)
273273
export(geom_density2d)
274+
export(geom_density_2d)
274275
export(geom_dotplot)
275276
export(geom_errorbar)
276277
export(geom_errorbarh)
@@ -432,6 +433,7 @@ export(stat_contour)
432433
export(stat_count)
433434
export(stat_density)
434435
export(stat_density2d)
436+
export(stat_density_2d)
435437
export(stat_ecdf)
436438
export(stat_ellipse)
437439
export(stat_function)

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ A number of geoms have been renamed to be internally consistent:
121121

122122
* `stat_binhex()` and `stat_bin2d()` have been renamed to `stat_bin_hex()`
123123
and `stat_bin_2d()` (#1274). `stat_summary2d()` has been renamed to
124-
`stat_summary_2d()`
124+
`stat_summary_2d()`, `geom_density2d()`/`stat_density2d()` has been renamed
125+
to `geom_density_2d()`/`stat_density_2d()`.
125126

126127
* `stat_spoke()` is now `geom_spoke()` since I realised it's a
127128
reparameterisation of `geom_segment().

R/geom-contour.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#'
66
#' @inheritParams geom_point
77
#' @inheritParams geom_path
8-
#' @seealso \code{\link{geom_density2d}}: 2d density contours
8+
#' @seealso \code{\link{geom_density_2d}}: 2d density contours
99
#' @export
1010
#' @export
1111
#' @examples
@@ -15,7 +15,7 @@
1515
#'
1616
#' # Or compute from raw data
1717
#' ggplot(faithful, aes(waiting, eruptions)) +
18-
#' geom_density2d()
18+
#' geom_density_2d()
1919
#'
2020
#' \donttest{
2121
#' # Setting bins creates evenly spaced contours in the range of the data

R/geom-density2d.r

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
#' results with contours. This can be useful for dealing with overplotting.
55
#'
66
#' @section Aesthetics:
7-
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "density2d")}
7+
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "density_2d")}
88
#'
99
#' @seealso \code{\link{geom_contour}} for contour drawing geom,
1010
#' \code{\link{stat_sum}} for another way of dealing with overplotting
1111
#' @param geom,stat Use to override the default connection between
12-
#' \code{geom_density2d} and \code{stat_density2d}.
12+
#' \code{geom_density_2d} and \code{stat_density_2d}.
1313
#' @inheritParams geom_point
1414
#' @inheritParams geom_path
1515
#' @export
@@ -18,23 +18,23 @@
1818
#' geom_point() +
1919
#' xlim(0.5, 6) +
2020
#' ylim(40, 110)
21-
#' m + geom_density2d()
21+
#' m + geom_density_2d()
2222
#' \donttest{
23-
#' m + stat_density2d(aes(fill = ..level..), geom = "polygon")
23+
#' m + stat_density_2d(aes(fill = ..level..), geom = "polygon")
2424
#'
25-
#' # If you map an aesthetic to a categorical variable, you will get a
26-
#' # set of contours for each value of that variable
2725
#' set.seed(4393)
2826
#' dsmall <- diamonds[sample(nrow(diamonds), 1000), ]
29-
#' d <- ggplot(dsmall, aes(x, y)) + geom_density2d(aes(colour = cut))
30-
#' d
27+
#' d <- ggplot(dsmall, aes(x, y))
28+
#' # If you map an aesthetic to a categorical variable, you will get a
29+
#' # set of contours for each value of that variable
30+
#' d + geom_density_2d(aes(colour = cut))
3131
#'
3232
#' # If we turn contouring off, we can use use geoms like tiles:
33-
#' d + stat_density2d(geom = "raster", aes(fill = ..density..), contour = FALSE)
33+
#' d + stat_density_2d(geom = "raster", aes(fill = ..density..), contour = FALSE)
3434
#' # Or points:
35-
#' d + stat_density2d(geom = "point", aes(size = ..density..), n = 20, contour = FALSE)
35+
#' d + stat_density_2d(geom = "point", aes(size = ..density..), n = 20, contour = FALSE)
3636
#' }
37-
geom_density2d <- function(mapping = NULL, data = NULL, stat = "density2d",
37+
geom_density_2d <- function(mapping = NULL, data = NULL, stat = "density2d",
3838
position = "identity", lineend = "butt",
3939
linejoin = "round", linemitre = 1,
4040
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,
@@ -57,6 +57,11 @@ geom_density2d <- function(mapping = NULL, data = NULL, stat = "density2d",
5757
)
5858
}
5959

60+
#' @export
61+
#' @rdname geom_density_2d
62+
#' @usage NULL
63+
geom_density2d <- geom_density_2d
64+
6065

6166
#' @rdname ggplot2-ggproto
6267
#' @format NULL

R/geom-point.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#' another. This can severely distort the visual appearance of the plot.
1717
#' There is no one solution to this problem, but there are some techniques
1818
#' that can help. You can add additional information with
19-
#' \code{\link{stat_smooth}}, \code{\link{stat_quantile}} or
20-
#' \code{\link{stat_density2d}}. If you have few unique x values,
19+
#' \code{\link{geom_smooth}}, \code{\link{geom_quantile}} or
20+
#' \code{\link{geom_density_2d}}. If you have few unique x values,
2121
#' \code{\link{geom_boxplot}} may also be useful. Alternatively, you can
2222
#' summarise the number of points at each location and display that in some
2323
#' way, using \code{\link{stat_sum}}. Another technique is to use transparent

R/stat-density-2d.r

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#' @export
2-
#' @rdname geom_density2d
2+
#' @rdname geom_density_2d
33
#' @param contour If \code{TRUE}, contour the results of the 2d density
44
#' estimation
55
#' @param n number of grid points in each direction
66
#' @param h Bandwidth (vector of length two). If \code{NULL}, estimated
77
#' using \code{\link[MASS]{bandwidth.nrd}}.
88
#' @section Computed variables:
99
#' Same as \code{\link{stat_contour}}
10-
stat_density2d <- function(mapping = NULL, data = NULL, geom = "density2d",
10+
stat_density_2d <- function(mapping = NULL, data = NULL, geom = "density_2d",
1111
position = "identity", contour = TRUE,
1212
n = 100, h = NULL, na.rm = FALSE,
1313
show.legend = NA, inherit.aes = TRUE, ...) {
@@ -28,6 +28,11 @@ stat_density2d <- function(mapping = NULL, data = NULL, geom = "density2d",
2828
)
2929
}
3030

31+
#' @export
32+
#' @rdname geom_density_2d
33+
#' @usage NULL
34+
stat_density2d <- stat_density_2d
35+
3136
#' @rdname ggplot2-ggproto
3237
#' @format NULL
3338
#' @usage NULL

inst/staticdocs/index.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sd_section("Geoms",
1212
"geom_curve",
1313
"geom_crossbar",
1414
"geom_density",
15-
"geom_density2d",
15+
"geom_density_2d",
1616
"geom_dotplot",
1717
"geom_errorbar",
1818
"geom_errorbarh",
@@ -50,7 +50,7 @@ sd_section("Statistics",
5050
"stat_binhex",
5151
"stat_contour",
5252
"stat_density",
53-
"stat_density2d",
53+
"stat_density_2d",
5454
"stat_ecdf",
5555
"stat_ellipse",
5656
"stat_function",

man/geom_contour.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.

man/geom_density2d.Rd renamed to man/geom_density_2d.Rd

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

man/geom_point.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.

0 commit comments

Comments
 (0)