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
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