ggplot2
ggplot2 copied to clipboard
Add `theme(axis.ontop)`
This PR aims to fix #6456.
It adds a new theme option that controls whether axes get displayed on top or below the panels.
The mechanism is changing the z value in the gtable.
By default, they are displayed on top of panels.
devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
p <- ggplot() +
annotate(
"rect", xmin = 0, xmax = 1, ymin = 0, ymax = 1,
colour = "dodgerblue", linewidth = 10, fill = NA
) +
coord_cartesian(
expand = FALSE,
clip = "off"
) +
theme(
axis.line = element_line("tomato", linewidth = 1)
)
p

Here they are displayed beneath panels.
p + theme(axis.ontop = FALSE)
