Skip to content

Commit d9f179b

Browse files
authored
theme docs - strip.text.x.* family (#5062)
1 parent 0d0de37 commit d9f179b

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

R/theme-defaults.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ theme_test <- function(base_size = 11, base_family = "",
619619
),
620620
strip.text.x = NULL,
621621
strip.text.y = element_text(angle = -90),
622+
strip.text.y.left = element_text(angle = 90),
622623
strip.placement = "inside",
623624
strip.placement.x = NULL,
624625
strip.placement.y = NULL,

R/theme.r

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,14 @@
152152
#' to the extend of the strip background? Options are `"on"` to clip, `"off"`
153153
#' to disable clipping or `"inherit"` (default) to take the clipping setting
154154
#' from the parent viewport.
155-
#' @param strip.text,strip.text.x,strip.text.y facet labels ([element_text()];
156-
#' inherits from `text`). Horizontal facet labels (`strip.text.x`) & vertical
155+
#' @param strip.text,strip.text.x,strip.text.y,strip.text.x.top,strip.text.x.bottom,strip.text.y.left,strip.text.y.right
156+
#' facet labels ([element_text()]; inherits from `text`). Horizontal facet labels (`strip.text.x`) & vertical
157157
#' facet labels (`strip.text.y`) inherit from `strip.text` or can be specified
158-
#' separately
158+
#' separately. Facet strips have dedicated position-dependent theme elements
159+
#' (`strip.text.x.top`, `strip.text.x.bottom`, `strip.text.y.left`, `strip.text.y.right`)
160+
#' that inherit from `strip.text.x` and `strip.text.y`, respectively.
161+
#' As a consequence, some theme stylings need to be applied to
162+
#' the position-dependent elements rather than to the parent elements
159163
#' @param strip.switch.pad.grid space between strips and axes when strips are
160164
#' switched (`unit`)
161165
#' @param strip.switch.pad.wrap space between strips and axes when strips are
@@ -266,6 +270,9 @@
266270
#'
267271
#' p3 + theme(strip.background = element_rect(colour = "black", fill = "white"))
268272
#' p3 + theme(strip.text.x = element_text(colour = "white", face = "bold"))
273+
#' # More direct strip.text.x here for top
274+
#' # as in the facet_wrap the default strip.position is "top"
275+
#' p3 + theme(strip.text.x.top = element_text(colour = "white", face = "bold"))
269276
#' p3 + theme(panel.spacing = unit(1, "lines"))
270277
#' }
271278
theme <- function(line,
@@ -358,13 +365,16 @@ theme <- function(line,
358365
strip.placement,
359366
strip.text,
360367
strip.text.x,
368+
strip.text.x.bottom,
369+
strip.text.x.top,
361370
strip.text.y,
371+
strip.text.y.left,
372+
strip.text.y.right,
362373
strip.switch.pad.grid,
363374
strip.switch.pad.wrap,
364375
...,
365376
complete = FALSE,
366-
validate = TRUE
367-
) {
377+
validate = TRUE) {
368378
elements <- find_args(..., complete = NULL, validate = NULL)
369379

370380
if (!is.null(elements$axis.ticks.margin)) {

man/theme.Rd

Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)