-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Layers have names #5967
Layers have names #5967
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Merge branch 'main' into named_layers # Conflicts: # R/plot-construction.R
We might see a few revdep failures on those packages that clone layers. I can fix my package easily, so this isn't a big problem to me, though. Just for sharing. |
Thanks for the heads up! Do you think it makes more sense to throw a warning instead of an error, and automatically make the names unique? |
Thanks. I think making it an error is a good idea. Imagining I would be a user of this feature, I think I would want to assume the names are unique. Let's revisit here if we find difficulty to enforce this change to the revdep packages. |
This PR aims to fix #4066.
Briefly, it sets names for the
layers
part of a plot that should be able to uniquely identify a layer. They're specified in theparams
argument tolayer()
and default toNULL
.As an example of using named layers, we see here that the
name
s provided to the layer end up as thenames
for the list of layers.By default,
name = NULL
, in which case a name is chosen for a layer. This defaults to the constructor function and that is not unique, it gets a suffix throughvec_as_names()
.Currently, you cannot set duplicated names. I was unsure whether the correct coarse here is to make names unique or throw an error. I decided it should throw an error on a whim, but I'd be happy to change this.
A quick demo that the names can be used to 'zap' layers.
Created on 2024-07-01 with reprex v2.1.0