Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggplot2 (development version)

* `stat_ydensity()` now only requires the `x` or `y` aesthetic. The other will
be populated with 0, similar to `stat_boxplot()` (@teunbrand, #6600)
* Implemented `as.list()` and `S7::convert()` methods for lists and classes in ggplot2
(@teunbrand, #6695)
* The default linetype in `geom_sf()` is derived from `geom_polygon()` for
Expand Down
8 changes: 7 additions & 1 deletion R/stat-ydensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @export
StatYdensity <- ggproto(
"StatYdensity", Stat,
required_aes = c("x", "y"),
required_aes = "x|y",
non_missing_aes = "weight",

setup_params = function(data, params) {
Expand All @@ -23,6 +23,12 @@ StatYdensity <- ggproto(
params
},

setup_data = function(self, data, params) {
var <- flipped_names(flip = params$flipped_aes)$x
data[[var]] <- data[[var]] %||% 0
data
},

# `draw_quantiles` is here for deprecation repair reasons
extra_params = c("na.rm", "orientation", "draw_quantiles"),

Expand Down