Closed teunbrand closed 1 month ago
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.
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