Skip to content

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

@teunbrand

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

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