Skip to content

Commit bf145fc

Browse files
authored
Merge pull request #300 from stan-dev/hist-bins
add 'bins' argument to many histogram plots
2 parents 621d52a + 3960eaa commit bf145fc

22 files changed

+587
-530
lines changed

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: bayesplot
22
Type: Package
33
Title: Plotting for Bayesian Models
4-
Version: 1.10.0.9000
5-
Date: 2022-11-16
4+
Version: 1.10.0.9001
5+
Date: 2023-03-16
66
Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"), email = "[email protected]"),
77
person("Tristan", "Mahr", role = "aut"),
88
person("Paul-Christian", "Bürkner", role = "ctb"),
@@ -55,7 +55,7 @@ Suggests:
5555
survival,
5656
testthat (>= 2.0.0),
5757
vdiffr (>= 1.0.2)
58-
RoxygenNote: 7.2.2
58+
RoxygenNote: 7.2.3
5959
VignetteBuilder: knitr
6060
Encoding: UTF-8
6161
Roxygen: list(markdown = TRUE)

R/mcmc-diagnostics.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ mcmc_rhat <- function(rhat, ..., size = NULL) {
171171

172172
#' @rdname MCMC-diagnostics
173173
#' @export
174-
mcmc_rhat_hist <- function(rhat, ..., binwidth = NULL, breaks = NULL) {
174+
mcmc_rhat_hist <- function(rhat, ..., binwidth = NULL, bins = NULL, breaks = NULL) {
175175
check_ignored_arguments(...)
176176
data <- mcmc_rhat_data(rhat)
177177

@@ -185,6 +185,7 @@ mcmc_rhat_hist <- function(rhat, ..., binwidth = NULL, breaks = NULL) {
185185
linewidth = 0.25,
186186
na.rm = TRUE,
187187
binwidth = binwidth,
188+
bins = bins,
188189
breaks = breaks
189190
) +
190191
scale_color_diagnostic("rhat") +
@@ -261,7 +262,7 @@ mcmc_neff <- function(ratio, ..., size = NULL) {
261262

262263
#' @rdname MCMC-diagnostics
263264
#' @export
264-
mcmc_neff_hist <- function(ratio, ..., binwidth = NULL, breaks = NULL) {
265+
mcmc_neff_hist <- function(ratio, ..., binwidth = NULL, bins = NULL, breaks = NULL) {
265266
check_ignored_arguments(...)
266267
data <- mcmc_neff_data(ratio)
267268

@@ -275,6 +276,7 @@ mcmc_neff_hist <- function(ratio, ..., binwidth = NULL, breaks = NULL) {
275276
linewidth = 0.25,
276277
na.rm = TRUE,
277278
binwidth = binwidth,
279+
bins = bins,
278280
breaks = breaks) +
279281
scale_color_diagnostic("neff") +
280282
scale_fill_diagnostic("neff") +

R/mcmc-distributions.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ mcmc_hist <- function(
115115
...,
116116
facet_args = list(),
117117
binwidth = NULL,
118+
bins = NULL,
118119
breaks = NULL,
119120
freq = TRUE,
120121
alpha = 1
@@ -127,6 +128,7 @@ mcmc_hist <- function(
127128
transformations = transformations,
128129
facet_args = facet_args,
129130
binwidth = binwidth,
131+
bins = bins,
130132
breaks = breaks,
131133
by_chain = FALSE,
132134
freq = freq,
@@ -180,6 +182,7 @@ mcmc_hist_by_chain <- function(
180182
...,
181183
facet_args = list(),
182184
binwidth = NULL,
185+
bins = NULL,
183186
freq = TRUE,
184187
alpha = 1
185188
) {
@@ -191,6 +194,7 @@ mcmc_hist_by_chain <- function(
191194
transformations = transformations,
192195
facet_args = facet_args,
193196
binwidth = binwidth,
197+
bins = bins,
194198
by_chain = TRUE,
195199
freq = freq,
196200
alpha = alpha,
@@ -369,6 +373,7 @@ mcmc_violin <- function(
369373
transformations = list(),
370374
facet_args = list(),
371375
binwidth = NULL,
376+
bins = NULL,
372377
breaks = NULL,
373378
by_chain = FALSE,
374379
freq = TRUE,
@@ -392,6 +397,7 @@ mcmc_violin <- function(
392397
size = .25,
393398
na.rm = TRUE,
394399
binwidth = binwidth,
400+
bins = bins,
395401
breaks = breaks,
396402
alpha = alpha
397403
)

R/mcmc-recover.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ mcmc_recover_hist <-
303303
...,
304304
facet_args = list(),
305305
binwidth = NULL,
306+
bins = NULL,
306307
breaks = NULL) {
307308

308309
check_ignored_arguments(...)
@@ -327,6 +328,7 @@ mcmc_recover_hist <-
327328
color = get_color("lh"),
328329
linewidth = 0.25,
329330
binwidth = binwidth,
331+
bins = bins,
330332
breaks = breaks
331333
) +
332334
geom_vline(

R/ppc-distributions.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ ppc_hist <-
362362
yrep,
363363
...,
364364
binwidth = NULL,
365+
bins = NULL,
365366
breaks = NULL,
366367
freq = TRUE) {
367368
check_ignored_arguments(...)
@@ -375,6 +376,7 @@ ppc_hist <-
375376
geom_histogram(
376377
linewidth = 0.25,
377378
binwidth = binwidth,
379+
bins = bins,
378380
breaks = breaks
379381
) +
380382
scale_fill_ppc() +

R/ppc-errors.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ ppc_error_hist <-
119119
...,
120120
facet_args = list(),
121121
binwidth = NULL,
122+
bins = NULL,
122123
breaks = NULL,
123124
freq = TRUE) {
124125

@@ -135,6 +136,7 @@ ppc_error_hist <-
135136
color = get_color("lh"),
136137
size = 0.25,
137138
binwidth = binwidth,
139+
bins = bins,
138140
breaks = breaks
139141
) +
140142
xlab(error_label()) +

R/ppc-test-statistics.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ ppc_stat <-
102102
stat = "mean",
103103
...,
104104
binwidth = NULL,
105+
bins = NULL,
105106
breaks = NULL,
106107
freq = TRUE) {
107108
stopifnot(length(stat) == 1)
@@ -127,6 +128,7 @@ ppc_stat <-
127128
linewidth = 0.25,
128129
na.rm = TRUE,
129130
binwidth = binwidth,
131+
bins = bins,
130132
breaks = breaks
131133
) +
132134
geom_vline(

R/ppd-distributions.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ ppd_hist <-
156156
function(ypred,
157157
...,
158158
binwidth = NULL,
159+
bins = NULL,
159160
breaks = NULL,
160161
freq = TRUE) {
161162
check_ignored_arguments(...)
@@ -169,6 +170,7 @@ ppd_hist <-
169170
geom_histogram(
170171
size = 0.25,
171172
binwidth = binwidth,
173+
bins = bins,
172174
breaks = breaks
173175
) +
174176
scale_color_ppd() +

R/ppd-test-statistics.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ ppd_stat <-
3636
stat = "mean",
3737
...,
3838
binwidth = NULL,
39+
bins = NULL,
3940
breaks = NULL,
4041
freq = TRUE) {
4142
stopifnot(length(stat) == 1)
@@ -59,6 +60,7 @@ ppd_stat <-
5960
linewidth = 0.25,
6061
na.rm = TRUE,
6162
binwidth = binwidth,
63+
bins = bins,
6264
breaks = breaks
6365
) +
6466
scale_color_ppd(guide = "none") +

man-roxygen/args-hist.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#' @param binwidth Passed to [ggplot2::geom_histogram()] to override
22
#' the default binwidth.
3-
#'
3+
#' @param bins Passed to [ggplot2::geom_histogram()] to override
4+
#' the default binwidth.
45
#' @param breaks Passed to [ggplot2::geom_histogram()] as an
56
#' alternative to `binwidth`.
67
#'

man/MCMC-diagnostics.Rd

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

man/MCMC-distributions.Rd

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

man/MCMC-recover.Rd

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

man/PPC-distributions.Rd

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

man/PPC-errors.Rd

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

man/PPC-test-statistics.Rd

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

man/PPD-distributions.Rd

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

man/PPD-test-statistics.Rd

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

tests/testthat/_snaps/mcmc-scatter-and-parcoord/mcmc-hex-bw.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)