Skip to content

layer does not work as expected for creating a geom_smooth plot #5572

Closed
@davidhodge931

Description

@davidhodge931
library(tidyverse)
library(palmerpenguins)

penguins |>
  ggplot(aes(x = flipper_length_mm,
             y = body_mass_g,)) +
  geom_smooth()
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_smooth()`).

penguins |>
  ggplot(aes(x = flipper_length_mm,
             y = body_mass_g,)) +
layer(
  geom = ggplot2::GeomSmooth,
  stat = "smooth",
  position = ggplot2::position_identity()
)
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_smooth()`).

Created on 2023-12-08 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions