Skip to content
Merged
Changes from 3 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
7 changes: 5 additions & 2 deletions R/stat-boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
StatBoxplot <- ggproto("StatBoxplot", Stat,
required_aes = c("y|x"),
non_missing_aes = "weight",
optional_aes = "width",
# either the x or y aesthetic will get dropped during
# statistical transformation, depending on the orientation
dropped_aes = c("x", "y", "weight"),
Expand Down Expand Up @@ -63,9 +64,11 @@ StatBoxplot <- ggproto("StatBoxplot", Stat,
if (any(outliers)) {
stats[c(1, 5)] <- range(c(stats[2:4], data$y[!outliers]), na.rm = TRUE)
}

if (vec_unique_count(data$x) > 1)
if (length(data$width) > 0L) {
width <- data$width[1L]
} else if (vec_unique_count(data$x) > 1) {
width <- diff(range(data$x)) * 0.9
}

df <- data_frame0(!!!as.list(stats))
df$outliers <- list(data$y[outliers])
Expand Down
Loading