Skip to content

Commit 9507433

Browse files
committed
Merge branch 'luca_updates'
2 parents df1d30c + 9d79994 commit 9507433

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

R/util_tplotfunctions.R

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ plot.probability <- function(
413413
#'
414414
#' @param p object of class "probability", obtained with \code{\link{Pr}} or \code{\link{tailPr}}.
415415
#' @param breaks `NULL` or as in function \code{\link[graphics]{hist}}. If `NULL` (default), an optimal number of breaks for each probability distribution is computed.
416+
#' @param alpha.f Numeric, default 0.125: opacity of the histogram filling. `0` means no filling.
416417
#' @param legend string or logical: plot a legend of the different curves at position `legend`? If `TRUE`, position is 'top'.
417418
#' @param ... other parameters to be passed to \code{\link{flexiplot}}.
418419
#'
@@ -424,6 +425,7 @@ hist.probability <- function(
424425
lty = c(1, 2, 4, 3, 6, 5),
425426
lwd = 2,
426427
col = palette(),
428+
alpha.f = 0.125,
427429
## c( ## Tol's colour-blind-safe scheme, or palette()
428430
## '#4477AA',
429431
## '#EE6677',
@@ -467,20 +469,35 @@ hist.probability <- function(
467469

468470
if(is.null(xlab)){xlab <- 'rel. frequency'}
469471
if(is.null(ylab)){ylab <- 'probability dens.'}
472+
if(isFALSE(alpha.f) || !is.numeric(alpha.f)){alpha.f <- 0}
470473

471474
if(missing(xlim)){xlim <- range(unlist(midslist))}
472475
if(is.na(ylim)[2]){ylim[2] <- max(unlist(densitylist))}
473476

474477
i <- 0L
475478
for(xx in seq_len(Xlen)){ for(yy in seq_len(Ylen)){
476479
i <- i + 1L
480+
x <- midslist[[i]]
481+
y <- densitylist[[i]]
482+
if(alpha.f > 0){
483+
plotquantiles(x = x, y = cbind(rep(0, length(y)), y),
484+
col = col[(i - 1) %% length(col) + 1],
485+
alpha.f = alpha.f,
486+
xlab = xlab, ylab = ylab,
487+
xlim = xlim, ylim = ylim,
488+
grid = grid,
489+
lty = 0,
490+
add = (add || i > 1),
491+
...)
492+
}
493+
477494
flexiplot(x = midslist[[i]], y = densitylist[[i]],
478495
xlab = xlab, ylab = ylab,
479496
xlim = xlim, ylim = ylim,
480497
col = col[(i - 1) %% length(col) + 1],
481498
lty = lty[(i - 1) %% length(lty) + 1],
482499
grid = grid,
483-
add = (add || i > 1),
500+
add = (add || alpha.f >0 || i > 1),
484501
...
485502
)
486503
} }

man/hist.probability.Rd

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

0 commit comments

Comments
 (0)