Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geom_textsmooth() doesn't choose method if not explicitly set #70

Closed
ccsarapas opened this issue Feb 19, 2022 · 2 comments · Fixed by #71
Closed

geom_textsmooth() doesn't choose method if not explicitly set #70

ccsarapas opened this issue Feb 19, 2022 · 2 comments · Fixed by #71

Comments

@ccsarapas
Copy link

geom_smooth() will choose a default smoothing method if one isn't specified, and ?geom_textpath says that it will also do this. But it actually issues a warning and returns a blank plot unless a method is explicitly set.

library(ggplot2)
library(geomtextpath)

## normal geom_smooth() behavior
ggplot(iris) +
  geom_smooth(
    aes(Sepal.Length, Sepal.Width, color = Species),
    se = FALSE
  )
# `geom_smooth()` using method = 'loess' and formula 'y ~ x'

iris1

## geom_textsmooth() yields warning and blank plot
ggplot(iris) +
  geom_textsmooth(
    aes(Sepal.Length, Sepal.Width, color = Species, label = Species),
    se = FALSE
  )
# `geom_smooth()` using formula 'y ~ x'
# Warning message:
# Computation failed in `stat_smooth()`:
# 'what' must be a function or character string 

iris2

## setting `method` = "loess" fixes it
ggplot(iris) +
  geom_textsmooth(
    aes(Sepal.Length, Sepal.Width, color = Species, label = Species),
    method = "loess",
    se = FALSE
  )
# `geom_smooth()` using formula 'y ~ x'

iris3

Software details:

OS Version: Windows 10 x64 (build 19044)
R Version: R version 4.1.2 (2021-11-01)
ggplot2 Version: 3.3.5
geomtextpath Version: 0.1.0
@teunbrand
Copy link
Collaborator

Hi there,

Thanks for the report, I can indeed confirm there is some kerfuffle around the method argument. I'll try to fix this soon-ish!

@teunbrand
Copy link
Collaborator

@AllanCameron only tangentially related to this; geom_textsmooth() never draws the standard error bands, but when a user sets se = TRUE, the position scales get trained with the +/- SE values. Should we just internally set se = FALSE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants