Skip to content

Use non-mapped, static aesthetic in ggplot() function as global default for geometries #6445

Open
@stragu

Description

@stragu

Just like it is possible to have "global" aesthetic mappings to variables inside ggplot()'s mapping = aes(), I think it would make sense to be able to set global defaults for static aesthetics as well. (They are currently ignored.)

For example:

library(ggplot2)
ggplot(data = mpg,
       mapping = aes(x = displ, y = hwy),
       colour = "orange") +
  geom_density_2d() +
  geom_point() +
  geom_smooth()
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

# ... should be equivalent to:
ggplot(data = mpg,
       mapping = aes(x = displ, y = hwy)) +
  geom_density_2d(colour = "orange") +
  geom_point(colour = "orange") +
  geom_smooth(colour = "orange")
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

Created on 2025-05-01 with reprex v2.1.1, ggplot2 3.5.2 and R 4.5.0.

(Apologies if this has been discussed before, I couldn't find a duplicate.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions