Skip to content

Commit 29c20c5

Browse files
authored
Document strip.placement.{x,y} (#6846)
* Add snapshot test for theme params * Document strip.placement.{x,y} * Add news bullet
1 parent c02c05a commit 29c20c5

7 files changed

Lines changed: 39 additions & 8 deletions

File tree

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
* New `position_dodge2(group.row)` argument that can be set to `"many"` to
3434
dodge groups with more than one row, such as in `geom_violin()`
3535
(@teunbrand, #6663)
36+
* `theme(strip.placement.x)` and `theme(strip.placement.y)` can be used for more
37+
granular control of strip placement when facetting. These have existed for some
38+
time but were not previously documented (@arcresu, #6827).
3639

3740
# ggplot2 4.0.2
3841

R/theme-sub.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ theme_sub_plot <- function(..., background, title, title.position, subtitle, cap
149149
#' @export
150150
#' @describeIn subtheme Theme specification for facet strips.
151151
theme_sub_strip <- function(..., background, background.x, background.y, clip,
152-
placement, text, text.x, text.x.bottom, text.x.top,
152+
placement, placement.x, placement.y,
153+
text, text.x, text.x.bottom, text.x.top,
153154
text.y, text.y.left, text.y.right,
154155
switch.pad.grid, switch.pad.wrap) {
155156
warn_dots_empty()

R/theme.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@
192192
#' inherits from `rect`). Horizontal facet background (`strip.background.x`)
193193
#' & vertical facet background (`strip.background.y`) inherit from
194194
#' `strip.background` or can be specified separately
195-
#' @param strip.placement placement of strip with respect to axes,
196-
#' either "inside" or "outside". Only important when axes and strips are
197-
#' on the same side of the plot.
195+
#' @param strip.placement,strip.placement.x,strip.placement.y
196+
#' placement of strip with respect to axes, either "inside" or "outside".
197+
#' Only important when axes and strips are on the same side of the plot.
198+
#' Horizontal (`strip.placement.x`) & vertical (`strip.placement.y`) placements
199+
#' inherit from `strip.placement` or can be specified separately
198200
#' @param strip.clip should strip background edges and strip labels be clipped
199201
#' to the extend of the strip background? Options are `"on"` to clip, `"off"`
200202
#' to disable clipping or `"inherit"` (default) to take the clipping setting
@@ -474,6 +476,8 @@ theme <- function(...,
474476
strip.background.y,
475477
strip.clip,
476478
strip.placement,
479+
strip.placement.x,
480+
strip.placement.y,
477481
strip.text,
478482
strip.text.x,
479483
strip.text.x.bottom,

man/subtheme.Rd

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

man/theme.Rd

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

tests/testthat/_snaps/theme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,16 @@
5858

5959
Unknown arguments to `element_text()`: `italic`, `fontweight`, and `fontwidth`.
6060

61+
# all expected theme elements are documented
62+
63+
Code
64+
extra_elements
65+
Output
66+
[1] "palette.colour.discrete" "palette.colour.continuous"
67+
[3] "palette.fill.discrete" "palette.fill.continuous"
68+
[5] "palette.alpha.discrete" "palette.alpha.continuous"
69+
[7] "palette.linewidth.discrete" "palette.linewidth.continuous"
70+
[9] "palette.size.discrete" "palette.size.continuous"
71+
[11] "palette.shape.discrete" "palette.shape.continuous"
72+
[13] "palette.linetype.discrete" "palette.linetype.continuous"
73+

tests/testthat/test-theme.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,3 +693,8 @@ test_that("legends are placed correctly when using stretchy spacing", {
693693
p + theme(legend.position = "top", legend.spacing.x = unit(1, "null"))
694694
)
695695
})
696+
697+
test_that("all expected theme elements are documented", {
698+
extra_elements <- setdiff(names(.element_tree), fn_fmls_names(theme))
699+
expect_snapshot(extra_elements)
700+
})

0 commit comments

Comments
 (0)