Skip to content

Add missing theme sub args #6492

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6491.

It integrates the panel.widths, panel.heights, axis.minor.ticks.length.{...} and axis.minor.ticks.{...} settings in the theme_sub_axis_*() family and theme_sub_panel() function.

A demo:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2

minor <- guide_axis(minor.ticks = TRUE)

ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  # Panel settings
  theme_sub_panel(
    widths = unit(5, "cm"),
    heights = unit(5, "cm")
  ) +
  # Minor ticks settings
  guides(x = minor, y = minor, x.sec = minor, y.sec = minor) +
  theme_sub_axis(minor.ticks.length = unit(5, "mm")) +
  theme_sub_axis_bottom(minor.ticks = element_line(colour = "red")) +
  theme_sub_axis_left(minor.ticks = element_line(colour = "limegreen")) +
  theme_sub_axis_right(minor.ticks = element_blank()) +
  theme_sub_axis_top(minor.ticks.length = unit(1, "mm"))

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

@teunbrand teunbrand added this to the ggplot2 4.0.0 milestone Jun 3, 2025
subtheme(find_args(), "axis.", ".x")
}

#' @export
#' @describeIn subtheme Theme specification for both y axes.
theme_sub_axis_y <- function(title, text, ticks, ticks.length, line) {
theme_sub_axis_y <- function(title, text, ticks, ticks.length, line, minor.ticks.length) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not minor.ticks argument for this and above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no theme(axis.minor.ticks), they all descent from the major ticks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then why do you have them below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should've been more specific: they descent from position-resolved major ticks. To illustrate: there is no minor.ticks.y because minor.ticks.y.left and minor.ticks.y.right descent from ticks.y.left and ticks.y.right respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

theme_sub_panel() should support the panel.widths and panel.heights setting
2 participants