Skip to content

theme_classic() panel grid should be set blank at parent #6320

Closed
@teunbrand

Description

@teunbrand

This was brought to my attention by @EvaMaeRey. Currently, we have the following situation where we cannot easily switch on the grid in theme_classic(). In the plot below, we would expect green gridlines.

library(ggplot2)

p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  theme_classic()

p + theme(panel.grid = element_line(colour = "limegreen"))

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

This is because theem_classic() sets the child elements to blank:

ggplot2/R/theme-defaults.R

Lines 499 to 500 in b87a6e3

panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),

Whereas it would make more sense to set the parent panel.grid to blank and let child elements inherit the usual route.

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