Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add minor ticks settings
  • Loading branch information
teunbrand committed Jun 2, 2025
commit 895dd2f3d3bea21299e11baa95ded57510f7ef1a
14 changes: 7 additions & 7 deletions R/theme-sub.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,43 @@ subtheme <- function(elements, prefix = "", suffix = "", call = caller_env()) {

#' @export
#' @describeIn subtheme Theme specification for all axes.
theme_sub_axis <- function(title, text, ticks, ticks.length, line) {
theme_sub_axis <- function(title, text, ticks, ticks.length, line, minor.ticks.length) {
subtheme(find_args(), "axis.")
}

#' @export
#' @describeIn subtheme Theme specification for both x axes.
theme_sub_axis_x <- function(title, text, ticks, ticks.length, line) {
theme_sub_axis_x <- function(title, text, ticks, ticks.length, line, minor.ticks.length) {
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.

Copy link
Member

Choose a reason for hiding this comment

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

I still find this weird but I trust your judgement

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 don't disagree with you, it is just the least-worst option I think.
We deliberated in #5287 (comment) wether inheritance should be like this:

             axis.ticks
            /          \
axis.ticks.x           axis.ticks.minor
     |                       |
axis.ticks.x.top       axis.ticks.minor.x
                             |
                       axis.ticks.minor.x.top

or like this:

axis.ticks
    |
axis.ticks.x
    |
axis.ticks.x.top
    |
axis.ticks.x.top.minor

Both are valid but eventually we chose option 2, with the minor ticks inheriting from the most specific major ticks,
That is why there is no axis.ticks.x.minor and axis.ticks.minor theme elements.
I'm happy to entertain alternative parentage for the minor ticks, but that is something we can delay until after release.

subtheme(find_args(), "axis.", ".y")
}

#' @export
#' @describeIn subtheme Theme specification for the bottom x axis.
theme_sub_axis_bottom <- function(title, text, ticks, ticks.length, line) {
theme_sub_axis_bottom <- function(title, text, ticks, ticks.length, line, minor.ticks, minor.ticks.length) {
subtheme(find_args(), "axis.", ".x.bottom")
}

#' @export
#' @describeIn subtheme Theme specification for the top x axis.
theme_sub_axis_top <- function(title, text, ticks, ticks.length, line) {
theme_sub_axis_top <- function(title, text, ticks, ticks.length, line, minor.ticks, minor.ticks.length) {
subtheme(find_args(), "axis.", ".x.top")
}

#' @export
#' @describeIn subtheme Theme specification for the left y axis.
theme_sub_axis_left <- function(title, text, ticks, ticks.length, line) {
theme_sub_axis_left <- function(title, text, ticks, ticks.length, line, minor.ticks, minor.ticks.length) {
subtheme(find_args(), "axis.", ".y.left")
}

#' @export
#' @describeIn subtheme Theme specification for the right y axis.
theme_sub_axis_right <- function(title, text, ticks, ticks.length, line) {
theme_sub_axis_right <- function(title, text, ticks, ticks.length, line, minor.ticks, minor.ticks.length) {
subtheme(find_args(), "axis.", ".y.right")
}

Expand Down
48 changes: 40 additions & 8 deletions man/subtheme.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.