Skip to content

Commit ae1ac75

Browse files
committed
rename prefix to theme_sub_*()
1 parent cbe3f15 commit ae1ac75

File tree

5 files changed

+82
-82
lines changed

5 files changed

+82
-82
lines changed

NAMESPACE

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -707,28 +707,28 @@ export(summarise_layout)
707707
export(sym)
708708
export(syms)
709709
export(theme)
710-
export(theme_axis)
711-
export(theme_axis_bottom)
712-
export(theme_axis_left)
713-
export(theme_axis_right)
714-
export(theme_axis_top)
715-
export(theme_axis_x)
716-
export(theme_axis_y)
717710
export(theme_bw)
718711
export(theme_classic)
719712
export(theme_dark)
720713
export(theme_get)
721714
export(theme_gray)
722715
export(theme_grey)
723-
export(theme_legend)
724716
export(theme_light)
725717
export(theme_linedraw)
726718
export(theme_minimal)
727-
export(theme_panel)
728-
export(theme_plot)
729719
export(theme_replace)
730720
export(theme_set)
731-
export(theme_strip)
721+
export(theme_sub_axis)
722+
export(theme_sub_axis_bottom)
723+
export(theme_sub_axis_left)
724+
export(theme_sub_axis_right)
725+
export(theme_sub_axis_top)
726+
export(theme_sub_axis_x)
727+
export(theme_sub_axis_y)
728+
export(theme_sub_legend)
729+
export(theme_sub_panel)
730+
export(theme_sub_plot)
731+
export(theme_sub_strip)
732732
export(theme_test)
733733
export(theme_update)
734734
export(theme_void)

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ggplot2 (development version)
22

33
* New function family for setting parts of a theme. For example, you can now use
4-
`theme_axis(line, text, ticks, ticks.length, line)` as a substitute for
4+
`theme_sub_axis(line, text, ticks, ticks.length, line)` as a substitute for
55
`theme(axis.line, axis.text, axis.ticks, axis.ticks.length, axis.line)`. This
66
should allow slightly terser and more organised theme declarations
77
(@teunbrand, #5301).

R/theme-sub.R

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#' )
2727
#'
2828
#' # Are equivalent to these less verbose theme settings
29-
#' p + theme_axis_bottom(
29+
#' p + theme_sub_axis_bottom(
3030
#' title = red_text,
3131
#' text = red_text,
3232
#' line = red_line,
@@ -54,85 +54,85 @@ subtheme <- function(elements, prefix = "", suffix = "", call = caller_env()) {
5454

5555
#' @export
5656
#' @describeIn subtheme Theme specification for all axes.
57-
theme_axis <- function(title, text, ticks, ticks.length, line) {
57+
theme_sub_axis <- function(title, text, ticks, ticks.length, line) {
5858
subtheme(find_args(), "axis.")
5959
}
6060

6161
#' @export
6262
#' @describeIn subtheme Theme specification for both x axes.
63-
theme_axis_x <- function(title, text, ticks, ticks.length, line) {
63+
theme_sub_axis_x <- function(title, text, ticks, ticks.length, line) {
6464
subtheme(find_args(), "axis.", ".x")
6565
}
6666

6767
#' @export
6868
#' @describeIn subtheme Theme specification for both y axes.
69-
theme_axis_y <- function(title, text, ticks, ticks.length, line) {
69+
theme_sub_axis_y <- function(title, text, ticks, ticks.length, line) {
7070
subtheme(find_args(), "axis.", ".y")
7171
}
7272

7373
#' @export
7474
#' @describeIn subtheme Theme specification for the bottom x axis.
75-
theme_axis_bottom <- function(title, text, ticks, ticks.length, line) {
75+
theme_sub_axis_bottom <- function(title, text, ticks, ticks.length, line) {
7676
subtheme(find_args(), "axis.", ".x.bottom")
7777
}
7878

7979
#' @export
8080
#' @describeIn subtheme Theme specification for the top x axis.
81-
theme_axis_top <- function(title, text, ticks, ticks.length, line) {
81+
theme_sub_axis_top <- function(title, text, ticks, ticks.length, line) {
8282
subtheme(find_args(), "axis.", ".x.top")
8383
}
8484

8585
#' @export
8686
#' @describeIn subtheme Theme specification for the left y axis.
87-
theme_axis_left <- function(title, text, ticks, ticks.length, line) {
87+
theme_sub_axis_left <- function(title, text, ticks, ticks.length, line) {
8888
subtheme(find_args(), "axis.", ".y.left")
8989
}
9090

9191
#' @export
9292
#' @describeIn subtheme Theme specification for the right y axis.
93-
theme_axis_right <- function(title, text, ticks, ticks.length, line) {
93+
theme_sub_axis_right <- function(title, text, ticks, ticks.length, line) {
9494
subtheme(find_args(), "axis.", ".y.right")
9595
}
9696

9797
#' @export
9898
#' @describeIn subtheme Theme specification for the legend.
99-
theme_legend <- function(background, margin, spacing, spacing.x, spacing.y,
100-
key, key.size, key.height, key.width, text, title,
101-
position, direction, justification, box, box.just,
102-
box.margin, box.background, box.spacing) {
99+
theme_sub_legend <- function(background, margin, spacing, spacing.x, spacing.y,
100+
key, key.size, key.height, key.width, text, title,
101+
position, direction, justification, box, box.just,
102+
box.margin, box.background, box.spacing) {
103103
subtheme(find_args(), "legend.")
104104
}
105105

106106
#' @export
107107
#' @describeIn subtheme Theme specification for the panels.
108-
theme_panel <- function(background, border, spacing, spacing.x, spacing.y,
109-
grid, grid.major, grid.minor, grid.major.x,
110-
grid.major.y, grid.minor.x, grid.minor.y, ontop) {
108+
theme_sub_panel <- function(background, border, spacing, spacing.x, spacing.y,
109+
grid, grid.major, grid.minor, grid.major.x,
110+
grid.major.y, grid.minor.x, grid.minor.y, ontop) {
111111
subtheme(find_args(), "panel.")
112112
}
113113

114114
#' @export
115115
#' @describeIn subtheme Theme specification for the whole plot.
116-
theme_plot <- function(background, title, title.position, subtitle, caption,
117-
caption.position, tag, tag.position, tag.location,
118-
margin) {
116+
theme_sub_plot <- function(background, title, title.position, subtitle, caption,
117+
caption.position, tag, tag.position, tag.location,
118+
margin) {
119119
subtheme(find_args(), "plot.")
120120
}
121121

122122
#' @export
123123
#' @describeIn subtheme Theme specification for facet strips.
124-
theme_strip <- function(background, background.x, background.y, clip,
125-
placement, text, text.x, text.x.bottom, text.x.top,
126-
text.y, text.y.left, text.y.right,
127-
switch.pad.grid, switch.pad.wrap) {
124+
theme_sub_strip <- function(background, background.x, background.y, clip,
125+
placement, text, text.x, text.x.bottom, text.x.top,
126+
text.y, text.y.left, text.y.right,
127+
switch.pad.grid, switch.pad.wrap) {
128128
subtheme(find_args(), "strip.")
129129
}
130130

131131
subtheme_param_doc <- function() {
132132
funs <- list(
133-
theme_axis, theme_axis_x, theme_axis_y, theme_axis_bottom,
134-
theme_axis_top, theme_axis_left, theme_axis_right, theme_legend,
135-
theme_panel, theme_plot, theme_strip
133+
theme_sub_axis, theme_sub_axis_x, theme_sub_axis_y, theme_sub_axis_bottom,
134+
theme_sub_axis_top, theme_sub_axis_left, theme_sub_axis_right, theme_sub_legend,
135+
theme_sub_panel, theme_sub_plot, theme_sub_strip
136136
)
137137
args <- sort(unique(unlist(lapply(funs, fn_fmls_names), use.names = FALSE)))
138138
paste0(

man/subtheme.Rd

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

tests/testthat/test-theme.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,17 @@ test_that("subtheme functions rename arguments as intended", {
515515
line <- element_line(colour = "red")
516516
rect <- element_rect(colour = "red")
517517

518-
expect_equal(theme_axis(ticks = line), theme(axis.ticks = line))
519-
expect_equal(theme_axis_x(ticks = line), theme(axis.ticks.x = line))
520-
expect_equal(theme_axis_y(ticks = line), theme(axis.ticks.y = line))
521-
expect_equal(theme_axis_top(ticks = line), theme(axis.ticks.x.top = line))
522-
expect_equal(theme_axis_bottom(ticks = line), theme(axis.ticks.x.bottom = line))
523-
expect_equal(theme_axis_left(ticks = line), theme(axis.ticks.y.left = line))
524-
expect_equal(theme_axis_right(ticks = line), theme(axis.ticks.y.right = line))
525-
expect_equal(theme_legend(key = rect), theme(legend.key = rect))
526-
expect_equal(theme_panel(border = rect), theme(panel.border = rect))
527-
expect_equal(theme_plot(background = rect), theme(plot.background = rect))
528-
expect_equal(theme_strip(background = rect), theme(strip.background = rect))
518+
expect_equal(theme_sub_axis(ticks = line), theme(axis.ticks = line))
519+
expect_equal(theme_sub_axis_x(ticks = line), theme(axis.ticks.x = line))
520+
expect_equal(theme_sub_axis_y(ticks = line), theme(axis.ticks.y = line))
521+
expect_equal(theme_sub_axis_top(ticks = line), theme(axis.ticks.x.top = line))
522+
expect_equal(theme_sub_axis_bottom(ticks = line), theme(axis.ticks.x.bottom = line))
523+
expect_equal(theme_sub_axis_left(ticks = line), theme(axis.ticks.y.left = line))
524+
expect_equal(theme_sub_axis_right(ticks = line), theme(axis.ticks.y.right = line))
525+
expect_equal(theme_sub_legend(key = rect), theme(legend.key = rect))
526+
expect_equal(theme_sub_panel(border = rect), theme(panel.border = rect))
527+
expect_equal(theme_sub_plot(background = rect), theme(plot.background = rect))
528+
expect_equal(theme_sub_strip(background = rect), theme(strip.background = rect))
529529

530530
# Test rejection of unknown theme elements
531531
expect_snapshot_warning(

0 commit comments

Comments
 (0)