Skip to content

Should theme(palette.* = ) raise a warning when options(ggplot2.* = ) is set? #6333

Closed
@yutannihilation

Description

@yutannihilation

I read the comments on #5946 and it's for the sake of compatibility that the new theme(palette.* = ) is enabled only when the corresponding palette is NULL. But, I feel it's a bit confusing to see theme(palette.* = ) is silently ignored.

Especially, if I were a theme developer, I will be afraid of inquiries like "Hey, your theme doesn't work on my machine, Why?" from those who set options(ggplot2.*). I think it's a rare case and not a serious issue, but I'm wondering if it's friendlier to show a warning.

library(ggplot2)

p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(colour = class)) +
  theme(
    palette.colour.discrete = scales::get_palette("mint")
  )

# theme is applied
p

options(ggplot2.discrete.colour = "viridis")

# ignored
p

Created on 2025-02-16 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions