Skip to content

Commit

Permalink
plotPedList() gains argument grouptitlesArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusdv committed Sep 7, 2024
1 parent 7547368 commit ccdee21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 11 additions & 4 deletions R/ped_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ plot.pedList = function(x, ...) {
#' structure of `plots`.
#' @param titles A character vector of titles for each group. Overrides titles
#' given in individuals subplots.
#' @param grouptitlesArgs A list of arguments passed on to [mtext()] for
#' `titles`.
#' @param frames A logical indicating if groups should be framed.
#' @param fmar A single number in the interval \eqn{[0,0.5)} controlling the
#' position of the frames.
Expand Down Expand Up @@ -417,7 +419,7 @@ plot.pedList = function(x, ...) {
#' @importFrom graphics grconvertX grconvertY layout mtext rect par plot
#' @export
plotPedList = function(plots, widths = NULL, groups = NULL, titles = NULL,
frames = TRUE, fmar = NULL, source = NULL,
grouptitlesArgs = NULL, frames = TRUE, fmar = NULL, source = NULL,
dev.height = NULL, dev.width = NULL,
newdev = !is.null(dev.height) || !is.null(dev.width),
verbose = FALSE, ...) {
Expand Down Expand Up @@ -519,7 +521,7 @@ plotPedList = function(plots, widths = NULL, groups = NULL, titles = NULL,
arglist[[parname]] = extra.args[[parname]]

# Remove inner title
arglist$title = NULL
#arglist$title = NULL

# Margins
arglist$margins = arglist$margins %||% {
Expand Down Expand Up @@ -596,8 +598,13 @@ plotPedList = function(plots, widths = NULL, groups = NULL, titles = NULL,
# Add titles
if(hasTitles) {
midpoints = if(!is.null(grouptitles)) (grStart + grStop)/2 else ratios[1:N] + diff(ratios)/2
cex.title = extra.args$cex.main %||% NA
mtext(finalTitles, outer = TRUE, at = midpoints, cex = cex.title, font = 2) # bold
gtArgs = list(text = finalTitles, at = midpoints, outer = TRUE, font = 2,
cex = extra.args$cex.main %||% NA)
if(!is.null(grouptitlesArgs))
gtArgs = modifyList(gtArgs, grouptitlesArgs)
#cex.title = extra.args$cex.main %||% NA
#mtext(finalTitles, outer = TRUE, at = midpoints, cex = cex.title,line = 0, font = 2)
do.call(mtext, gtArgs)
}
}

Expand Down
4 changes: 4 additions & 0 deletions man/plotPedList.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ccdee21

Please sign in to comment.