Skip to content

Commit 91c8bf1

Browse files
committed
stat-density-2d lets through bins & binwidth
This was a regression due to the `...` refactoring. Fixes #1448
1 parent 98f3515 commit 91c8bf1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
## Bug fixes and minor improvements
44

55
* `stat-density-2d()` no longer ignores the `h` parameter.
6+
7+
* `stat-density-2d()` now accepts `bins` and `binwidth` parameters
8+
to control the number of contour levels (#1448, @has2k1).
9+
610
# ggplot2 2.0.0
711

812
## Major changes

R/stat-density-2d.r

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ StatDensity2d <- ggproto("StatDensity2d", Stat,
4444
required_aes = c("x", "y"),
4545

4646
compute_group = function(data, scales, na.rm = FALSE, h = NULL,
47-
contour = TRUE, n = 100) {
47+
contour = TRUE, n = 100, bins = NULL,
48+
binwidth = NULL) {
4849
if (is.null(h)) {
4950
h <- c(MASS::bandwidth.nrd(data$x), MASS::bandwidth.nrd(data$y))
5051
}
@@ -57,7 +58,7 @@ StatDensity2d <- ggproto("StatDensity2d", Stat,
5758
df$group <- data$group[1]
5859

5960
if (contour) {
60-
StatContour$compute_panel(df, scales)
61+
StatContour$compute_panel(df, scales, bins, binwidth)
6162
} else {
6263
names(df) <- c("x", "y", "density", "group")
6364
df$level <- 1

0 commit comments

Comments
 (0)