Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack divide zero #6341

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6338.

Briefly, it prevents position_fill() from "filling" when all observations are zero, which would previously generate NAs through division by zero.

Reprex from the issue, note the lack of warning about missing values:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2

df <-
  tibble::tribble(
    ~season,   ~family, ~count,
    "Summer",    "Bird",    10,
    "Summer",    "Fish",    12,
    "Winter",    "Bird",     4,
    "Winter",    "Fish",     1
  )

df |>
  ggplot(aes(x = season, y = count, fill = family, group = family)) +
  geom_area(position = position_fill())

Created on 2025-02-19 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New warning missing values or values outside the scale range with geom_area(position = position_fill())
1 participant