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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ up correct aspect ratio, and draws a graticule.
* In all layers that use it, `linemitre` now defaults to 10 (instead of 1)
to better match base R.

* `geom_boxplot()` now supplies default value if no `x` aesthetic present
(@foo-bar-baz-qux, #2110).

* `geom_density()` drops groups with fewer than two data points and throws a
warning. For groups with two data points, the density values are now
calculated with `stats::density` (@karawoo, #2127).
Expand Down
8 changes: 6 additions & 2 deletions R/stat-boxplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ stat_boxplot <- function(mapping = NULL, data = NULL,
#' @usage NULL
#' @export
StatBoxplot <- ggproto("StatBoxplot", Stat,
required_aes = c("x", "y"),
required_aes = c("y"),
non_missing_aes = "weight",
setup_data = function(data, params) {
data$x <- data$x %||% 0
data
},

setup_params = function(data, params) {
params$width <- params$width %||% (resolution(data$x) * 0.75)
params$width <- params$width %||% (resolution(data$x %||% 0) * 0.75)

if (is.double(data$x) && !has_groups(data) && any(data$x != data$x[1L])) {
warning(
Expand Down