Skip to content

Commit 5afbc67

Browse files
Revert ppc_rootogram changes per review — handle separately
ppc_rootogram has mixed size semantics (line width + point size) that need their own design. Reverted to master state as requested.
1 parent 13ff1fa commit 5afbc67

5 files changed

Lines changed: 24 additions & 45 deletions

File tree

R/ppc-discrete.R

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#' @param size,linewidth For bar plots, `size` and `linewidth` are passed to
2222
#' [ggplot2::geom_pointrange()] to control the appearance of the `yrep` points
2323
#' and intervals, where `size` controls the point size and `linewidth` controls
24-
#' the line width. For rootograms `size` is passed to [ggplot2::geom_point()]
25-
#' and [ggplot2::geom_pointrange()].
24+
#' the line width. For rootograms `size` is passed to
25+
#' [ggplot2::geom_line()] and [ggplot2::geom_pointrange()].
2626
#' @param fatten Deprecated. Point size is now controlled directly by `size`.
2727
#' @param freq For bar plots only, if `TRUE` (the default) the y-axis will
2828
#' display counts. Setting `freq=FALSE` will put proportions on the y-axis.
@@ -278,32 +278,11 @@ ppc_rootogram <- function(y,
278278
style = c("standing", "hanging", "suspended", "discrete"),
279279
...,
280280
prob = 0.9,
281-
size = NULL,
282-
linewidth = NULL,
281+
size = 1,
283282
bound_distinct = TRUE) {
284283
check_ignored_arguments(...)
285284
style <- match.arg(style)
286285

287-
if (!is.null(size) && !is.null(linewidth)) {
288-
abort(paste0(
289-
"Both `size` and `linewidth` were supplied to `ppc_rootogram()`. ",
290-
"Use `size` for point size and `linewidth` for line width."
291-
))
292-
}
293-
if (!is.null(size) && is.null(linewidth)) {
294-
lifecycle::deprecate_warn(
295-
"1.16.0",
296-
"ppc_rootogram(size)",
297-
details = paste0(
298-
"Previously `size` controlled both point size and line width. ",
299-
"Now use `size` for point size and `linewidth` for line width."
300-
)
301-
)
302-
linewidth <- size
303-
}
304-
size <- size %||% 1
305-
linewidth <- linewidth %||% 1
306-
307286
data <- .ppc_rootogram_data(
308287
y = y,
309288
yrep = yrep,
@@ -335,15 +314,16 @@ ppc_rootogram <- function(y,
335314
geom_pointrange(
336315
aes(y = .data$pred_median, ymin = .data$lower, ymax = .data$upper, color = "y_rep"),
337316
fill = get_color("lh"),
338-
linewidth = linewidth,
317+
linewidth = size,
339318
size = size,
319+
fatten = 2,
340320
alpha = 1
341321
)
342322
} else {
343323
geom_smooth(
344324
aes(x = .data$xpos, y = .data$tyexp, color = "Expected"),
345325
fill = get_color("d"),
346-
linewidth = linewidth,
326+
linewidth = size,
347327
stat = "identity"
348328
)
349329
}

man/PPC-discrete.Rd

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

tests/testthat/_snaps/ppc-discrete/ppc-rootogram-discrete-bound-distinct-false.svg

Lines changed: 6 additions & 6 deletions
Loading

tests/testthat/_snaps/ppc-discrete/ppc-rootogram-style-discrete-prob-size.svg

Lines changed: 6 additions & 6 deletions
Loading

tests/testthat/test-ppc-discrete.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ test_that("ppc_rootogram renders correctly", {
166166
y = vdiff_y2,
167167
yrep = vdiff_yrep2,
168168
prob = 2/3,
169-
linewidth = 3,
169+
size = 3,
170170
style = "hanging"
171171
)
172172

@@ -178,7 +178,7 @@ test_that("ppc_rootogram renders correctly", {
178178
y = vdiff_y2,
179179
yrep = vdiff_yrep2,
180180
prob = 0.5,
181-
linewidth = 1,
181+
size = 1,
182182
style = "discrete"
183183
)
184184

@@ -190,7 +190,7 @@ test_that("ppc_rootogram renders correctly", {
190190
y = vdiff_y2,
191191
yrep = vdiff_yrep2,
192192
prob = 0.8,
193-
linewidth = 1,
193+
size = 1,
194194
style = "discrete",
195195
bound_distinct = FALSE
196196
)

0 commit comments

Comments
 (0)