Repository navigation
Layers have names - #5967
Merged
Merged
Layers have names#5967
Conversation
Merge branch 'main' into named_layers # Conflicts: # R/plot-construction.R
Member
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. |
Collaborator
Author
|
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? |
Member
|
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 was referenced Jan 22, 2025
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to fix #4066.
Briefly, it sets names for the
layerspart of a plot that should be able to uniquely identify a layer. They're specified in theparamsargument tolayer()and default toNULL.As an example of using named layers, we see here that the
names provided to the layer end up as thenamesfor 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