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

Inheritance of theme-based aesthetics #6285

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Jan 21, 2025

This PR is an amendment to #5833.

Briefly, we want to deprecate update_geom_defaults() and to do that we need to increase the flexibility of the theme based styling of geom defaults. In this PR, we include inheritance of theme-based aesthetics to allow finer customisation.

In order to make this not too restrictive, we're allowing any theme(geom.* = element_geom()), which takes same logic in terms of theme validation.

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

class(GeomDensity)
#> [1] "GeomDensity" "GeomArea"    "GeomRibbon"  "Geom"        "ggproto"    
#> [6] "gg"

ggplot(mpg, aes(displ)) +
  geom_density() +
  theme(
    geom.ribbon = element_geom(borderwidth = 2),
    geom.area = element_geom(bordertype = 2),
    geom.density = element_geom(ink = "red")
  )

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

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

Successfully merging this pull request may close these issues.

1 participant