Skip to content

Commit 3d65697

Browse files
authored
Swap underscore arguments for dot-case arguments (#5754)
* deprecate underscore args in `coord_radial()` * deprecate underscore args in `guide_axis_logticks()` * use snapshot text for underscore arguments * redocument * Swap args in tests * sort snapshot * forgot to update snapshot
1 parent 35a3440 commit 3d65697

File tree

9 files changed

+352
-55
lines changed

9 files changed

+352
-55
lines changed

R/coord-radial.R

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
#' @param expand If `TRUE`, the default, adds a small expansion factor the
88
#' the limits to prevent overlap between data and axes. If `FALSE`, limits
99
#' are taken directly from the scale.
10-
#' @param r_axis_inside If `TRUE`, places the radius axis inside the
10+
#' @param r.axis.inside If `TRUE`, places the radius axis inside the
1111
#' panel. If `FALSE`, places the radius axis next to the panel. The default,
1212
#' `NULL`, places the radius axis outside if the `start` and `end` arguments
1313
#' form a full circle.
14-
#' @param rotate_angle If `TRUE`, transforms the `angle` aesthetic in data
14+
#' @param rotate.angle If `TRUE`, transforms the `angle` aesthetic in data
1515
#' in accordance with the computed `theta` position. If `FALSE` (default),
1616
#' no such transformation is performed. Can be useful to rotate text geoms in
1717
#' alignment with the coordinates.
1818
#' @param inner.radius A `numeric` between 0 and 1 setting the size of a inner.radius hole.
19+
#' @param r_axis_inside,rotate_angle `r lifecycle::badge("deprecated")`
1920
#'
2021
#' @note
2122
#' In `coord_radial()`, position guides are can be defined by using
@@ -36,15 +37,30 @@ coord_radial <- function(theta = "x",
3637
expand = TRUE,
3738
direction = 1,
3839
clip = "off",
39-
r_axis_inside = NULL,
40-
rotate_angle = FALSE,
41-
inner.radius = 0) {
40+
r.axis.inside = NULL,
41+
rotate.angle = FALSE,
42+
inner.radius = 0,
43+
r_axis_inside = deprecated(),
44+
rotate_angle = deprecated()) {
45+
46+
if (lifecycle::is_present(r_axis_inside)) {
47+
deprecate_warn0(
48+
"3.5.1", "coord_radial(r_axis_inside)", "coord_radial(r.axis.inside)"
49+
)
50+
r.axis.inside <- r_axis_inside
51+
}
52+
if (lifecycle::is_present(rotate_angle)) {
53+
deprecate_warn0(
54+
"3.5.1", "coord_radial(rotate_angle)", "coord_radial(rotate.angle)"
55+
)
56+
rotate.angle <- rotate_angle
57+
}
4258

4359
theta <- arg_match0(theta, c("x", "y"))
4460
r <- if (theta == "x") "y" else "x"
45-
check_bool(r_axis_inside, allow_null = TRUE)
61+
check_bool(r.axis.inside, allow_null = TRUE)
4662
check_bool(expand)
47-
check_bool(rotate_angle)
63+
check_bool(rotate.angle)
4864
check_number_decimal(start, allow_infinite = FALSE)
4965
check_number_decimal(end, allow_infinite = FALSE, allow_null = TRUE)
5066
check_number_decimal(inner.radius, min = 0, max = 1, allow_infinite = FALSE)
@@ -54,16 +70,16 @@ coord_radial <- function(theta = "x",
5470
n_rotate <- ((start - end) %/% (2 * pi)) + 1
5571
start <- start - n_rotate * 2 * pi
5672
}
57-
r_axis_inside <- r_axis_inside %||% !(abs(end - start) >= 1.999 * pi)
73+
r.axis.inside <- r.axis.inside %||% !(abs(end - start) >= 1.999 * pi)
5874

5975
ggproto(NULL, CoordRadial,
6076
theta = theta,
6177
r = r,
6278
arc = c(start, end),
6379
expand = expand,
6480
direction = sign(direction),
65-
r_axis_inside = r_axis_inside,
66-
rotate_angle = rotate_angle,
81+
r_axis_inside = r.axis.inside,
82+
rotate_angle = rotate.angle,
6783
inner_radius = c(inner.radius, 1) * 0.4,
6884
clip = clip
6985
)

R/guide-axis-logticks.R

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@ NULL
1010
#' the (relative) length of the long, middle and short ticks. Numeric values
1111
#' are interpreted as [rel()] objects. The [rel()] values are used to multiply
1212
#' values of the `axis.ticks.length` theme setting.
13-
#' @param prescale_base Base of logarithm used to transform data manually. The
13+
#' @param prescale.base Base of logarithm used to transform data manually. The
1414
#' default, `NULL`, will use the scale transformation to calculate positions.
15-
#' Only set `prescale_base` if the data has already been log-transformed.
15+
#' Only set `prescale.base` if the data has already been log-transformed.
1616
#' When using a log-transform in the position scale or in `coord_trans()`,
1717
#' keep the default `NULL` argument.
18-
#' @param negative_small When the scale limits include 0 or negative numbers,
18+
#' @param negative.small When the scale limits include 0 or negative numbers,
1919
#' what should be the smallest absolute value that is marked with a tick?
20-
#' @param short_theme A theme [element][element_line()] for customising the
20+
#' @param short.theme A theme [element][element_line()] for customising the
2121
#' display of the shortest ticks. Must be a line or blank element, and
2222
#' it inherits from the `axis.minor.ticks` setting for the relevant position.
2323
#' @param expanded Whether the ticks should cover the range after scale
2424
#' expansion (`TRUE`, default), or be restricted to the scale limits
2525
#' (`FALSE`).
26+
#' @param prescale_base,negative_small,short_theme `r lifecycle::badge("deprecated")`
2627
#' @inheritParams guide_axis
2728
#' @inheritDotParams guide_axis -minor.ticks
2829
#'
@@ -41,12 +42,12 @@ NULL
4142
#' p + coord_trans(x = "log10", y = "log10") +
4243
#' guides(x = "axis_logticks", y = "axis_logticks")
4344
#'
44-
#' # When data is transformed manually, one should provide `prescale_base`
45+
#' # When data is transformed manually, one should provide `prescale.base`
4546
#' # Keep in mind that this axis uses log10 space for placement, not log2
4647
#' p + aes(x = log2(bodywt), y = log10(brainwt)) +
4748
#' guides(
48-
#' x = guide_axis_logticks(prescale_base = 2),
49-
#' y = guide_axis_logticks(prescale_base = 10)
49+
#' x = guide_axis_logticks(prescale.base = 2),
50+
#' y = guide_axis_logticks(prescale.base = 10)
5051
#' )
5152
#'
5253
#' # A plot with both positive and negative extremes, pseudo-log transformed
@@ -61,20 +62,42 @@ NULL
6162
#' # The log ticks are mirrored when 0 is included
6263
#' p2 + guides(x = "axis_logticks")
6364
#'
64-
#' # To control the tick density around 0, one can set `negative_small`
65-
#' p2 + guides(x = guide_axis_logticks(negative_small = 1))
65+
#' # To control the tick density around 0, one can set `negative.small`
66+
#' p2 + guides(x = guide_axis_logticks(negative.small = 1))
6667
guide_axis_logticks <- function(
6768
long = 2.25,
6869
mid = 1.5,
6970
short = 0.75,
70-
prescale_base = NULL,
71-
negative_small = 0.1,
72-
short_theme = element_line(),
71+
prescale.base = NULL,
72+
negative.small = 0.1,
73+
short.theme = element_line(),
7374
expanded = TRUE,
7475
cap = "none",
7576
theme = NULL,
77+
prescale_base = deprecated(),
78+
negative_small = deprecated(),
79+
short_theme = deprecated(),
7680
...
7781
) {
82+
if (lifecycle::is_present(prescale_base)) {
83+
deprecate_warn0(
84+
"3.5.1", "guide_axis_logticks(prescale_base)", "guide_axis_logticks(prescale.base)"
85+
)
86+
prescale.base <- prescale_base
87+
}
88+
if (lifecycle::is_present(negative_small)) {
89+
deprecate_warn0(
90+
"3.5.1", "guide_axis_logticks(negative_small)", "guide_axis_logticks(negative.small)"
91+
)
92+
negative.small <- negative_small
93+
}
94+
if (lifecycle::is_present(short_theme)) {
95+
deprecate_warn0(
96+
"3.5.1", "guide_axis_logticks(short_theme)", "guide_axis_logticks(short.theme)"
97+
)
98+
short.theme <- short_theme
99+
}
100+
78101
if (is.logical(cap)) {
79102
check_bool(cap)
80103
cap <- if (cap) "both" else "none"
@@ -91,24 +114,24 @@ guide_axis_logticks <- function(
91114
check_object(mid, check_fun, what)
92115
check_object(short, check_fun, what)
93116
check_number_decimal(
94-
negative_small, min = 1e-100, # minimal domain of scales::log_trans
117+
negative.small, min = 1e-100, # minimal domain of scales::log_trans
95118
allow_infinite = FALSE,
96119
allow_null = TRUE
97120
)
98121
check_bool(expanded)
99-
check_inherits(short_theme, c("element_blank", "element_line"))
122+
check_inherits(short.theme, c("element_blank", "element_line"))
100123

101124
new_guide(
102125
available_aes = c("x", "y"),
103-
prescale_base = prescale_base,
104-
negative_small = negative_small,
126+
prescale_base = prescale.base,
127+
negative_small = negative.small,
105128
expanded = expanded,
106129
long = long,
107130
mid = mid,
108131
short = short,
109132
cap = cap,
110133
minor.ticks = TRUE,
111-
short_theme = short_theme,
134+
short_theme = short.theme,
112135
theme = theme,
113136
...,
114137
super = GuideAxisLogticks
@@ -152,7 +175,7 @@ GuideAxisLogticks <- ggproto(
152175
trans_name <- scale$get_transformation()$name
153176
if (trans_name != "identity") {
154177
cli::cli_warn(paste0(
155-
"The {.arg prescale_base} argument will override the scale's ",
178+
"The {.arg prescale.base} argument will override the scale's ",
156179
"{.field {trans_name}} transformation in log-tick positioning."
157180
))
158181
}

man/coord_polar.Rd

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

man/guide_axis_logticks.Rd

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

tests/testthat/_snaps/guides.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
# guide_axis_logticks calculates appropriate ticks
5656

57-
The `prescale_base` argument will override the scale's log-10 transformation in log-tick positioning.
57+
The `prescale.base` argument will override the scale's log-10 transformation in log-tick positioning.
5858

5959
# binning scales understand the different combinations of limits, breaks, labels, and show.limits
6060

0 commit comments

Comments
 (0)