Hi ggplot2 experts,
Is it possible to identify with code via ggplot_build
whether or not a plot contains a geom that includes polygons?
library(tidyverse)
library(palmerpenguins)
p1 <- penguins |>
ggplot() +
geom_point(aes(x = sex, y = body_mass_g))
p1_build <- ggplot_build(p1)
p2 <- penguins |>
ggplot() +
geom_boxplot(aes(x = sex, y = body_mass_g))
p2_build <- ggplot_build(p2)
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_boxplot()`).
Created on 2023-12-05 with reprex v2.0.2