Open
Description
There are situations where it would nice to be able to easily make the the axis line/ticks not be on top of geoms.
I noticed the theme argument has a panel.ontop argument. So I wondered if you guys would consider adding equivalent theme arguments for the axis.
Something like theme(axis.ontop = TRUE, axis.ontop.x = TRUE, axis.ontop.y = TRUE)
.
I suppose for consistency with the existing theme grammar, these axis arguments should apply to the axis text too.
Thanks for your consideration, and the great ggplot2 dev work!
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggplot2)
library(palmerpenguins)
#>
#> Attaching package: 'palmerpenguins'
#> The following objects are masked from 'package:datasets':
#>
#> penguins, penguins_raw
d <- penguins |>
add_row(
flipper_length_mm = 190,
body_mass_g = 2500,
species = "Adelie",
) |>
add_row(
flipper_length_mm = 165,
body_mass_g = 3000,
species = "Adelie",
)
p <- d |>
ggplot() +
geom_point(aes(x = flipper_length_mm, y = body_mass_g),
colour = "steelblue", size = 3) +
theme_classic() +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
coord_cartesian(clip = "off")
p
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#so something like this to make the axis line/ticks not ontop
# p +
# theme(axis.ontop = FALSE)
#
# p +
# theme(axis.ontop.x = FALSE) +
# theme(axis.ontop.y = FALSE)
Created on 2025-05-14 with reprex v2.1.1
Metadata
Metadata
Assignees
Labels
No labels