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

Feature request: allow adding aesthetics together #5884

Closed
billdenney opened this issue May 4, 2024 · 2 comments
Closed

Feature request: allow adding aesthetics together #5884

billdenney opened this issue May 4, 2024 · 2 comments

Comments

@billdenney
Copy link
Contributor

In situations when I am programming around ggplot2 to modify figures, I would like to be able to add aesthetics together.

The goal would be to allow modification of existing figures or plotting routines in a simpler way.

library(ggplot2)

aes(x = A) + aes(y = B) # equals aes(x = A, y = B)
aes(x = A, colour = D) + aes(x = C, y = B) # equals aes(x = C, y = B, colour = D)
aes(x = A) + NULL # equals aes(x = A)

I think that the above is the most useful. But, while setting up operations for aesthetics, I think that having a method to subtract could also be useful. I think that the default subtraction method should be that it removes the aesthetic:

library(ggplot2)

aes(x = A) - aes(y = B) # no change, possibly with a warning aes(x = A)
aes(x = A, colour = D) - aes(x = C, y = B) # equals aes(colour = D)
aes(x = A) - NULL # no change aes(x = A)
@teunbrand
Copy link
Collaborator

Hi thanks for the suggestion!

This (or something very similar to this) has been discussed in #4789.
The outcome of that discussion was that the splicing mechanism (see #2675) is preferred over further overloading the + operator.

@billdenney
Copy link
Contributor Author

Ah, thanks for pointing out the prior discussion. My search didn't find that. This is resolved, then.

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

No branches or pull requests

2 participants