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

No ticks no space #6071

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@
* New theme elements `palette.{aes}.discrete` and `palette.{aes}.continuous`.
Theme palettes replace palettes in scales where `palette = NULL`, which is
the new default in many scales (@teunbrand, #4696).
* `guide_axis()` no longer reserves space for blank ticks
(@teunbrand, #4722, #6069).

# ggplot2 3.5.1

Expand Down
6 changes: 6 additions & 0 deletions R/guide-axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ GuideAxis <- ggproto(
override_elements = function(params, elements, theme) {
elements$text <-
label_angle_heuristic(elements$text, params$position, params$angle)
if (inherits(elements$ticks, "element_blank")) {
elements$major_length <- unit(0, "cm")
}
if (inherits(elements$minor, "element_blank") || isFALSE(params$minor.ticks)) {
elements$minor_length <- unit(0, "cm")
}
return(elements)
},

Expand Down
6 changes: 5 additions & 1 deletion R/theme-defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,11 @@ theme_minimal <- function(base_size = 11, base_family = "",
ink = ink, paper = paper
) %+replace%
theme(
axis.ticks = element_blank(),
axis.ticks = element_blank(), # Extra margins due to absence ticks
axis.text.x.bottom = element_text(margin = margin(t = 0.45 * base_size)),
axis.text.x.top = element_text(margin = margin(b = 0.45 * base_size)),
axis.text.y.left = element_text(margin = margin(r = 0.45 * base_size)),
axis.text.y.right = element_text(margin = margin(l = 0.45 * base_size)),
legend.background = element_blank(),
legend.key = element_blank(),
panel.background = element_blank(),
Expand Down
Loading