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

Length check for after_scale() aesthetics #5901

Closed
teunbrand opened this issue May 22, 2024 · 1 comment · Fixed by #5902
Closed

Length check for after_scale() aesthetics #5901

teunbrand opened this issue May 22, 2024 · 1 comment · Fixed by #5902

Comments

@teunbrand
Copy link
Collaborator

I acknowledge that this is user-error, but the error message could be a little bit more informative here:

library(ggplot2)

ggplot(mpg[15:16, ], aes(displ, hwy)) +
  geom_point(
    aes(colour = after_scale(c("red", "green", "blue")))
  )
#> Error in `geom_point()`:
#> ! Problem while setting up geom aesthetics.
#> ℹ Error occurred in the 1st layer.
#> Caused by error in `data.frame()`:
#> ! arguments imply differing number of rows: 3, 2

Created on 2024-05-22 with reprex v2.1.0

In particular, it could inform for which aesthetics the length was incorrect, to give a hint as to what to fix.
Moreover, I think this needn't be an error, but just a warning that applying these modifications failed.

@teunbrand
Copy link
Collaborator Author

Same holds for after_stat():

library(ggplot2)

ggplot(mpg[15:16, ], aes(displ, hwy)) +
  geom_point(aes(
    colour = after_stat(c("A", "B", "C"))
  ))
#> Error in `geom_point()`:
#> ! Problem while mapping stat to aesthetics.
#> ℹ Error occurred in the 1st layer.
#> Caused by error in `data.frame()`:
#> ! arguments imply differing number of rows: 3, 2

Created on 2024-05-22 with reprex v2.1.0

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.

1 participant