davidhodge931 / ggblanket

Simplify ggplot2 visualisation
https://davidhodge931.github.io/ggblanket/
Other
149 stars 8 forks source link

docs: rationale for oob_keep #928

Closed davidhodge931 closed 3 weeks ago

davidhodge931 commented 1 month ago
library(tidyverse)
library(palmerpenguins)
library(patchwork)

p <- penguins |>
  ggplot(aes(x = flipper_length_mm, y = bill_length_mm, colour = species, fill = species)) +
  geom_smooth() +
  # geom_point() +
  theme(legend.position = "none")

p1 <- p +
  scale_y_continuous(limits = c(35, 55), expand = c(0, 0)) 

p2 <- p +
  scale_y_continuous(limits = c(35, 55), expand = c(0, 0), oob = scales::oob_keep) 

p + p1 + p2
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_smooth()`).
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> Warning: Removed 16 rows containing non-finite outside the scale range
#> (`stat_smooth()`).
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_smooth()`).

Created on 2024-07-01 with reprex v2.1.0