Skip to content

Warning in geom_col() when panel has 0 rows #5632

Closed

Description

@teunbrand

This is a slightly contrived example, but the bar's width calculation can be chatty when there is a factor level in the PANEL that has 0 rows in the data.

library(ggplot2)

df <- mpg
df$drv <- factor(df$drv, c("4", "f", "r"))

ggplot(subset(df, drv != "4"), aes(cyl, cty)) +
  geom_col() +
  facet_wrap(~ drv, drop = FALSE)
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
#> Warning in min(d[d > tolerance]): no non-missing arguments to min; returning
#> Inf

Created on 2024-01-05 with reprex v2.0.2

Activity

  1. teunbrand commented on Jan 15, 2024

    @teunbrand
    CollaboratorAuthor

    Considered closed by #5633.

  2. averissimo commented on Dec 18, 2025

    @averissimo

    There has been a regreesion and this error is still present on 4.0.1 when running the reprex I get the exact same warnings.

    edit: nevermind, it's not present on the development branch so it must've been fixed.

  3. teunbrand commented on Dec 18, 2025

    @teunbrand
    CollaboratorAuthor

    Yes #6759 took care of this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions