Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ggplot2 (development version)

* Fixed spurious warnings when the `weight` was used in `stat_bin_2d()`,
`stat_boxplot()`, `stat_contour()`, `stat_bin_hex()` and `stat_quantile()`
(@teunbrand, #5216).
* The `layer_data()`, `layer_scales()` and `layer_grob()` now have the default
`plot = last_plot()` (@teunbrand, #5166).
* To prevent changing the plotting order, `stat_sf()` is now computed per panel
Expand Down
4 changes: 3 additions & 1 deletion R/stat-bin2d.r
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ StatBin2d <- ggproto("StatBin2d", Stat,
out$density <- out$count / sum(out$count, na.rm = TRUE)
out$ndensity <- out$density / max(out$density, na.rm = TRUE)
out
}
},

dropped_aes = "weight" # No longer available after transformation
)

dual_param <- function(x, default = list(x = NULL, y = NULL)) {
Expand Down
5 changes: 4 additions & 1 deletion R/stat-binhex.r
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ StatBinhex <- ggproto("StatBinhex", Stat,
out$value <- NULL

out
}
},

# weight is no longer available after transformation
dropped_aes = "weight"
)

2 changes: 1 addition & 1 deletion R/stat-boxplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ StatBoxplot <- ggproto("StatBoxplot", Stat,
non_missing_aes = "weight",
# either the x or y aesthetic will get dropped during
# statistical transformation, depending on the orientation
dropped_aes = c("x", "y"),
dropped_aes = c("x", "y", "weight"),
setup_data = function(self, data, params) {
data <- flip_data(data, params$flipped_aes)
data$x <- data$x %||% 0
Expand Down
6 changes: 4 additions & 2 deletions R/stat-contour.r
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ StatContour <- ggproto("StatContour", Stat,

required_aes = c("x", "y", "z"),
default_aes = aes(order = after_stat(level)),
dropped_aes = "z", # z gets dropped during statistical transformation
# z and weight get dropped during statistical transformation
dropped_aes = c("z", "weight"),

setup_params = function(data, params) {
params$z.range <- range(data$z, na.rm = TRUE, finite = TRUE)
Expand Down Expand Up @@ -120,7 +121,8 @@ StatContourFilled <- ggproto("StatContourFilled", Stat,

required_aes = c("x", "y", "z"),
default_aes = aes(order = after_stat(level), fill = after_stat(level)),
dropped_aes = "z", # z gets dropped during statistical transformation
# z and weight get dropped during statistical transformation
dropped_aes = c("z", "weight"),

setup_params = function(data, params) {
params$z.range <- range(data$z, na.rm = TRUE, finite = TRUE)
Expand Down
5 changes: 4 additions & 1 deletion R/stat-quantile.r
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ StatQuantile <- ggproto("StatQuantile", Stat,
method.args = method.args
)
vec_rbind0(!!!result)
}
},

# weight is no longer available after transformation
dropped_aes = "weight"
)

quant_pred <- function(quantile, data, method, formula, weight, grid,
Expand Down