Skip to content
Open
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
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
(@mitchelloharawild, #6609).
* Fixed regression where `scale_{x,y}_*()` threw an error when an expression
object is set to `labels` argument (@yutannihilation, #6617).


* `stat_ydensity()` now only requires the `x` or `y` aesthetic. The other will
be populated with 0, similar to `stat_boxplot()` (@teunbrand, #6600)
* Allow `stat` in `geom_hline`, `geom_vline`, and `geom_abline`. (@sierrajohnson, #6559)

# ggplot2 4.0.0
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
Loading