Skip to content

Commit 8f8ee2c

Browse files
committed
increasing ggplot vers to 3.5.0+ and fixing discrete grouped rootogram
1 parent 8677e51 commit 8f8ee2c

4 files changed

Lines changed: 95 additions & 79 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Depends:
3131
R (>= 4.1.0)
3232
Imports:
3333
dplyr (>= 1.0.0),
34-
ggplot2 (>= 3.4.0),
34+
ggplot2 (>= 3.5.0),
3535
ggridges (>= 0.5.5),
3636
glue,
3737
lifecycle,

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Use `"neff_ratio"` consistently in diagnostic color scale helpers to avoid relying on partial matching of `"neff"`.
1919
* Replace `expand = c(mult, add)` with `ggplot2::expansion()` helper in scale functions for consistency with ggplot2 >= 3.3.0 style.
2020
* Replace uses of `geom_bar(stat = "identity")` with the more idiomatic ggplot2 form `geom_col()`
21+
* New function `ppc_rootogram_grouped` for grouped rootogram plots by @behramulukir and @jgabry (#419)
2122

2223
# bayesplot 1.15.0
2324

R/ppc-discrete.R

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,16 @@ ppc_rootogram_grouped <-
406406
g <- eval(ungroup_call("ppc_rootogram", call), parent.frame())
407407

408408
# In style = discrete, scale_y_sqrt() can't handle -Inf values in axis segments
409-
# so force_axes_in_facets() results in errors
410-
if (style != "discrete") {
409+
#
410+
use_native_axes <- style == "discrete" && fixed_y(facet_args)
411+
if (!use_native_axes) {
411412
g <- g + force_axes_in_facets()
412413
}
413-
414-
g + bars_group_facets(facet_args)
414+
g + bars_group_facets(
415+
facet_args,
416+
force_axes = use_native_axes,
417+
axis_labels_default = "margins"
418+
)
415419
}
416420

417421

@@ -517,9 +521,15 @@ ppc_bars_data <-
517521
#' `bayesplot::intervals_group_facets()`, which has a default of `"free"`.
518522
#' @return Object returned by `facet_wrap()`.
519523
#' @noRd
520-
bars_group_facets <- function(facet_args, scales_default = "fixed") {
524+
bars_group_facets <- function(facet_args, scales_default = "fixed", force_axes = FALSE, axis_labels_default = "all") {
521525
facet_args[["facets"]] <- "group"
522526
facet_args[["scales"]] <- facet_args[["scales"]] %||% scales_default
527+
528+
if (force_axes) {
529+
facet_args[["axes"]] <- facet_args[["axes"]] %||% "all"
530+
facet_args[["axis.labels"]] <- facet_args[["axis.labels"]] %||% axis_labels_default
531+
}
532+
523533
do.call("facet_wrap", facet_args)
524534
}
525535

0 commit comments

Comments
 (0)