Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yutannihilation opened this issue Feb 15, 2025 · 2 comments · May be fixed by #6334
Open

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

yutannihilation opened this issue Feb 15, 2025 · 2 comments · May be fixed by #6334

Comments

@yutannihilation
Copy link
Member

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

@teunbrand
Copy link
Collaborator

Mechanically, would you propose to detect this situation whenever theme() is called, or when scale_colour_*() is called?

@yutannihilation
Copy link
Member Author

Oh, I expected the latter, but former should be also fine.

@teunbrand teunbrand linked a pull request Feb 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants