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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ggplot2 (development version)

* `position_fill()` avoids stacking observations of zero (@teunbrand, #6338)
* New parameters for `geom_label()` (@teunbrand and @steveharoz, #5365):
* The `linewidth` aesthetic is now applied and replaces the `label.size`
argument.
Expand Down
5 changes: 4 additions & 1 deletion R/position-stack.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@
heights <- c(0, cumsum(y))

if (fill) {
heights <- heights / abs(heights[length(heights)])
total <- abs(heights[length(heights)])
if (total > sqrt(.Machine$double.eps)) {
heights <- heights / total

Check warning on line 229 in R/position-stack.R

View check run for this annotation

Codecov / codecov/patch

R/position-stack.R#L227-L229

Added lines #L227 - L229 were not covered by tests
}
}
# We need to preserve ymin/ymax order. If ymax is lower than ymin in input, it should remain that way
if (!is.null(df$ymin) && !is.null(df$ymax)) {
Expand Down
Loading