Skip to content

Updating scale instead of replacing #6346

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

Closed
jbengler opened this issue Feb 25, 2025 · 2 comments
Closed

Updating scale instead of replacing #6346

jbengler opened this issue Feb 25, 2025 · 2 comments

Comments

@jbengler
Copy link

Hi Teun!

I’ve always wondered about this. Is there a way to update a scale instead of replacing it, similar to how theme() works?

If not, would there be a way to implement this?

library(ggplot2)

p <- 
  mtcars |> 
  ggplot(aes(disp, drat)) +
  geom_point()

# themes are updated
p + 
  theme(panel.grid.major = element_line(color = "pink")) + 
  theme(panel.grid.minor = element_line(color = "blue"))

# scales are replaced
p +
  scale_x_continuous(limits = c(100, 200)) +
  scale_x_continuous(trans = "log10")

Best
Jan

@teunbrand
Copy link
Collaborator

Hi Jan!
You might be interested in #6196, which roughly follows the pattern you describe. If I'm understanding you correctly, this issue is in essence a duplicate of #4269 and we can continue discussion over at there.

@jbengler
Copy link
Author

That is great! PR #6196 is exactly what I had in mind.
Sorry for the duplicate. I have to get better in finding relevant issues and PRs 🙄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants