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

non-standard params / geom-specific metadata #1694

Closed
tdhock opened this issue Aug 3, 2016 · 5 comments
Closed

non-standard params / geom-specific metadata #1694

tdhock opened this issue Aug 3, 2016 · 5 comments
Labels
feature a feature request or enhancement
Milestone

Comments

@tdhock
Copy link
Contributor

tdhock commented Aug 3, 2016

Hello, this is continuing the discussion from #1649 and #1585 our equivalent animint issue is tdhock/animint#159

For https://github.com/tdhock/animint we need some way of specifying chunk_vars which is a geom-specific parameter that has nothing to do with how it appears. With old ggplot2 (pre-2.0) the following was working fine

ggplot()+
  geom_point(aes(Sepal.Length, Petal.Length, showSelected=Species),
    data=iris, 
    chunk_vars=character())

With current ggplot2 that now results in an error

Error: Unknown parameters: chunk_vars

Basically we just need a way for ggplot2 to store that information in the geom, ideally without throwing any errors/warnings/messages. The use case is described by @faizan-khan-iit 's excellent test case from his PR 017b0f3 -- we want the geom to store whatever information is provided in those non-standard parameters, so it can be accessed later by our animint code.

One way to achieve this would be to use Faizan's validate_params=FALSE method #1649 but that PR was rejected by @hadley

Let me propose another way:

l <- geom_point(aes(Sepal.Length, Petal.Length, showSelected=Species), 
    data=iris, 
    meta=list(chunk_vars=character()))

meta should be recognized by ggplot2 as a special meta-data parameter (no warnings or messages about meta being an unknown parameter). whatever was specified as meta should be accessible via l$meta Comments?

@thomasp85
Copy link
Member

It makes a bit more sense now, though I'm still unsure if this is the best approach. Is there any sense in different layers having different settings for chunk_vars? What I'm getting at is, couldn't this option be set globally rather than through each geom?

@tdhock
Copy link
Contributor Author

tdhock commented Aug 3, 2016

yes each layer has a different value of chunk_vars

for global options we already have a PR accepted for non-standard theme options #1121

@tdhock
Copy link
Contributor Author

tdhock commented Aug 12, 2016

hey @thomasp85 @hadley can you please comment on this approach for adding geom-specific metadata? If this is not appropriate can you please explain why, and suggest and alternative?

@tdhock tdhock changed the title non-standard params non-standard params / geom-specific metadata Aug 12, 2016
@hadley hadley added this to the v2.2.0 milestone Sep 23, 2016
@hadley hadley added the feature a feature request or enhancement label Sep 23, 2016
@hadley
Copy link
Member

hadley commented Sep 23, 2016

Well, the good news is that you'll no longer get an error, but you'll now get a warning for both the aesthetic and the parameter.

Can you remind me why you don't want to provide your own geom functions with extra parameters?

@tdhock
Copy link
Contributor Author

tdhock commented Sep 26, 2016

Thanks! That solves this issue then.

I guess we could provide our own geom functions with extra parameters, but I did not want to have to copy all the geom code to animint, and make users have to learn new geom functions.

@tdhock tdhock closed this as completed Sep 26, 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
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants