Skip to content

Commit b08c93d

Browse files
committed
stat_bin_2d(boundary) internally defaults to 0
1 parent 917045a commit b08c93d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

R/stat-bin2d.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ stat_bin_2d <- function(mapping = NULL, data = NULL,
1616
...,
1717
bins = 30,
1818
binwidth = NULL,
19-
boundary = 0,
2019
drop = TRUE,
2120
na.rm = FALSE,
2221
show.legend = NA,
@@ -33,7 +32,6 @@ stat_bin_2d <- function(mapping = NULL, data = NULL,
3332
bins = bins,
3433
binwidth = binwidth,
3534
drop = drop,
36-
boundary = boundary,
3735
na.rm = na.rm,
3836
...
3937
)
@@ -58,11 +56,14 @@ StatBin2d <- ggproto(
5856

5957
compute_group = function(data, scales, binwidth = NULL, bins = 30,
6058
breaks = NULL, origin = NULL, drop = TRUE,
61-
boundary = 0, closed = NULL, center = NULL) {
59+
boundary = NULL, closed = NULL, center = NULL) {
6260

6361
data$z <- data$weight %||% 1
6462
data$weight <- NULL
6563

64+
# For backward compatibility, boundary defaults to 0
65+
boundary <- boundary %||% if (is.null(center)) list(x = 0, y = 0)
66+
6667
out <- StatSummary2d$compute_group(
6768
data, scales, binwidth = binwidth, bins = bins, breaks = breaks,
6869
drop = drop, fun = "sum", boundary = boundary, closed = closed,

R/stat-summary-2d.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ StatSummary2d <- ggproto("StatSummary2d", Stat,
100100

101101
params <- fix_bin_params(params, fun = snake_class(self), version = "3.5.2")
102102
vars <- c("origin", "binwidth", "breaks", "center", "boundary")
103-
params[vars] <- lapply(params[vars], dual_param)
103+
params[vars] <- lapply(params[vars], dual_param, default = NULL)
104104
params$closed <- dual_param(params$closed, list(x = "right", y = "right"))
105105

106106
params

0 commit comments

Comments
 (0)