Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* New functions `mcmc_dots` and `mcmc_dots_by_chain` for dot plots of MCMC draws by @behramulukir (#402)
* Default to `quantiles=100` for all dot plots by @behramulukir (#402)
* Use `"neff_ratio"` consistently in diagnostic color scale helpers to avoid relying on partial matching of `"neff"`.
* Replace old-style `expand = c(mult, add)` with `expansion()` helper in scale functions across `helpers-gg.R`, `mcmc-diagnostics.R`, `mcmc-diagnostics-nuts.R`, `mcmc-distributions.R`, and `mcmc-parcoord.R` for consistency with ggplot2 >= 3.3.0 style.

# bayesplot 1.15.0

Expand Down
4 changes: 2 additions & 2 deletions R/helpers-gg.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ modify_aes <- function(mapping, ...) {
facet_wrap_parsed <- function(...) {
facet_wrap(..., labeller = label_parsed)
}
dont_expand_y_axis <- function(expand = c(0,0)) {
dont_expand_y_axis <- function(expand = expansion(0, 0)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the default here is good, but there are still places in the code where we call e.g.

dont_expand_y_axis(c(0.005, 0))

in which case this is still using the old behavior.

scale_y_continuous(expand = expand)
}
dont_expand_x_axis <- function(expand = c(0,0)) {
dont_expand_x_axis <- function(expand = expansion(0, 0)) {
scale_x_continuous(expand = expand)
}
dont_expand_axes <- function() {
Expand Down
2 changes: 1 addition & 1 deletion R/mcmc-diagnostics-nuts.R
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ mcmc_nuts_energy <-
scale_fill_manual("", values = fills, labels = aes_labs) +
scale_color_manual("", values = clrs, labels = aes_labs) +
dont_expand_y_axis(c(0.005, 0)) +
scale_x_continuous(expand = c(0.2, 0)) +
scale_x_continuous(expand = expansion(mult = 0.2, add = 0)) +
labs(y = NULL, x = expression(E - bar(E))) +
bayesplot_theme_get() +
space_legend_keys() +
Expand Down
8 changes: 4 additions & 4 deletions R/mcmc-diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ mcmc_rhat <- function(rhat, ..., size = NULL) {
labs(y = NULL, x = expression(hat(R))) +
scale_fill_diagnostic("rhat") +
scale_color_diagnostic("rhat") +
scale_x_continuous(breaks = brks, expand = c(0, .01)) +
scale_y_discrete(expand = c(.025,0)) +
scale_x_continuous(breaks = brks, expand = expansion(mult = 0, add = 0.01)) +
scale_y_discrete(expand = expansion(mult = 0.025, add = 0)) +
yaxis_title(FALSE) +
yaxis_text(FALSE) +
yaxis_ticks(FALSE)
Expand Down Expand Up @@ -262,7 +262,7 @@ mcmc_neff <- function(ratio, ..., size = NULL) {
# as.character truncates trailing zeroes, while ggplot default does not
labels = as.character(breaks),
limits = c(0, max(1, max_ratio) + 0.05),
expand = c(0, 0)) +
expand = expansion(0, 0)) +
bayesplot_theme_get() +
yaxis_text(FALSE) +
yaxis_title(FALSE) +
Expand Down Expand Up @@ -574,7 +574,7 @@ drop_NAs_and_warn <- function(x) {
scale_x_continuous(
limits = c(-0.5, lags + 0.5),
breaks = function(x) as.integer(pretty(x, n = 3)),
expand = c(0, 0)
expand = expansion(0, 0)
) +
labs(x = "Lag", y = "Autocorrelation") +
force_axes_in_facets()
Expand Down
2 changes: 1 addition & 1 deletion R/mcmc-distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ mcmc_dens_chains <- function(
labs(color = "Chain") +
scale_y_discrete(
limits = unique(rev(data$parameter)),
expand = c(0.05, .6)
expand = expansion(mult = 0.05, add = 0.6)
) +
scale_color +
bayesplot_theme_get() +
Expand Down
2 changes: 1 addition & 1 deletion R/mcmc-parcoord.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ mcmc_parcoord <-
}

graph +
scale_x_discrete(expand = c(0,0), labels = levels(draws$Parameter)) +
scale_x_discrete(expand = expansion(0, 0), labels = levels(draws$Parameter)) +
expand_limits(x = nlevels(draws$Parameter) + 0.25) +
labs(x = NULL, y = NULL)
}
Expand Down
Loading