Skip to content

Cannot pass check.aes through geom_* to layer #1869

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

Closed
wmurphyrd opened this issue Oct 23, 2016 · 1 comment
Closed

Cannot pass check.aes through geom_* to layer #1869

wmurphyrd opened this issue Oct 23, 2016 · 1 comment

Comments

@wmurphyrd
Copy link

My colorplaner ggplot2 extension involves a scale which accepts an aesthetic unknown to the layer and maps that aesthetic to one the layer accepts (specifically, a secondary color/fill mapping translated through a bivariate color scale to color or fill).

With the changes in befc4d0 for issue #1585, a warning is now generated if that mapping is created at the layer level:

library(ggplot2)
library(colorplaner)
ggplot(mtcars, aes(x = drat, y = mpg)) +
  geom_point(aes(color = hp, color2 = disp)) +
  scale_color_colorplane()
Warning: Ignoring unknown aesthetics: color2

In this instance the warning is untrue, as the scale interprets color2 and the plot is generated as expected. However, since the layers are ignorant of their scales, I cannot figure out a solution to inform the layers of the scale's handling of the aesthetic to avoid this warning. This isn't a show stopper as the mapping can simply be done at the plot level or the warning can be ignored, but it could certainly introduce confusion to users.

The layer function now includes a check.aes parameter option to skip this checking, but it does not seem possible to pass that parameter through the standard geom_* constructors, as the ... arguments to geom_* get wrapped up in a params list passed on to layer (e.g. in geom_point here).

ggplot(mtcars, aes(x = drat, y = mpg)) +
  geom_point(aes(color = hp, unknown_aes = disp), check.aes = FALSE)
Warning: Ignoring unknown parameters: check.aes
Warning: Ignoring unknown aesthetics: unknown_aes

Would you consider a PR that altered layer() to look for and honor check.aes and check.param within its params argument?

@hadley
Copy link
Member

hadley commented Oct 24, 2016

I definitely don't want to go down that route because it makes check.aes and check.param behave differently to the other layer parameters. Basically the problem is that you're trying to extend ggplot2 in a way that it wasn't designed to be extended, and you're going to keep running into these problems. I don't think there will be an elegant fix - you'll just need to figure out how to hack around the problem somehow.

@hadley hadley closed this as completed Oct 24, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants