Skip to content

Stability of layer names #6295

Description

@teunbrand

This problem was identified in #6287 and affects 7 packages.

In #5967 we gave layers names. However, some packages insist in manually managing the plot$layers field, which can cause names to disappear. We don't have a good fallback for this situation, but we should. Generally this tends to become a problem after adding >1 layer.

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point()

# To wipe out names
p$layers <- list(geom_path())
p + geom_point() + geom_point()
#> Error:
#> ! Names repair functions can't return `NA` values.

Created on 2025-01-22 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions