From 69d533f01cbe24576e8128926d4664a4bc5f0998 Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Mon, 12 Sep 2022 09:49:39 +0200 Subject: [PATCH 1/3] Add sub_toptitle_size parameter about subtitle size in PlotLayout --- R/PlotLayout.R | 9 ++++++++- man/PlotLayout.Rd | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/R/PlotLayout.R b/R/PlotLayout.R index 742478e..f59b832 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -216,6 +216,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, title_scale = 1, title_margin_scale = 1, title_left_shift_scale = 1, subtitle_scale = 1, subtitle_margin_scale = 1, + sub_toptitle_size = 1, brks = NULL, cols = NULL, drawleg = 'S', titles = NULL, subsampleg = NULL, bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, col_sup = NULL, @@ -392,6 +393,11 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, stop("Parameter 'subtite_margin_scale' must be numeric.") } + # Check sub_toptitle_size + if (!is.numeric(sub_toptitle_size)) { + stop("Parameter 'sub_toptitle_size' must be numeric.") + } + # Check titles if (!all(sapply(titles, is.character))) { stop("Parameter 'titles' must be a vector of character strings.") @@ -665,7 +671,8 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, fun_args <- c(fun_args, list(brks = colorbar$brks, cols = colorbar$cols, col_inf = colorbar$col_inf, col_sup = colorbar$col_sup, - drawleg = FALSE)) + drawleg = FALSE, + title_scale = sub_toptitle_size)) } do.call(fun[[array_number]], fun_args) plot_number <<- plot_number + 1 diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index f8e7bae..36f84d8 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -21,6 +21,7 @@ PlotLayout( title_left_shift_scale = 1, subtitle_scale = 1, subtitle_margin_scale = 1, + sub_toptitle_size = 1, brks = NULL, cols = NULL, drawleg = "S", -- GitLab From d7f4a7db07fa82703398844f3e5cf8444e99be39 Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Wed, 14 Sep 2022 10:11:20 +0200 Subject: [PATCH 2/3] Change subplot_title_scale and added subplot_margin_scale to PlotLayout --- R/PlotLayout.R | 20 +++++++++++++++----- man/PlotLayout.Rd | 9 ++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/R/PlotLayout.R b/R/PlotLayout.R index f59b832..0b693a1 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -101,6 +101,10 @@ #' (specified in 'row_titles' and 'col_titles'). Takes 1 by default. #'@param subtitle_margin_scale Scale factor for the margins surrounding the #' subtitles. Takes 1 by default. +#'@param subplot_titles_scale Scale factor for the subplots top titles. Takes +#' 1 by default. +#'@param subplot_margin_scale Scale factor for the margins surrounding the +#' subplots, with the format c(y1, x1, y2, x2). Defaults to rep(1, 4). #'@param units Title at the top of the colour bar, most commonly the units of #' the variable provided in parameter 'var'. #'@param brks,cols,bar_limits,triangle_ends Usually only providing 'brks' is @@ -216,7 +220,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, title_scale = 1, title_margin_scale = 1, title_left_shift_scale = 1, subtitle_scale = 1, subtitle_margin_scale = 1, - sub_toptitle_size = 1, + subplot_titles_scale = 1, subplot_margin_scale = rep(1, 4), brks = NULL, cols = NULL, drawleg = 'S', titles = NULL, subsampleg = NULL, bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, col_sup = NULL, @@ -393,9 +397,14 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, stop("Parameter 'subtite_margin_scale' must be numeric.") } - # Check sub_toptitle_size - if (!is.numeric(sub_toptitle_size)) { - stop("Parameter 'sub_toptitle_size' must be numeric.") + # Check subplot_titles_scale + if (!is.numeric(subplot_titles_scale)) { + stop("Parameter 'subplot_titles_scale' must be numeric.") + } + + # subplot_margin_scale + if (!is.numeric(subplot_margin_scale) || length(subplot_margin_scale) != 4) { + stop("Parameter 'subplot_margin_scale' must be a numeric vector with 4 elements.") } # Check titles @@ -672,7 +681,8 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, col_inf = colorbar$col_inf, col_sup = colorbar$col_sup, drawleg = FALSE, - title_scale = sub_toptitle_size)) + title_scale = subplot_titles_scale, + margin_scale = subplot_margin_scale)) } do.call(fun[[array_number]], fun_args) plot_number <<- plot_number + 1 diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index 36f84d8..f634cfc 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -21,7 +21,8 @@ PlotLayout( title_left_shift_scale = 1, subtitle_scale = 1, subtitle_margin_scale = 1, - sub_toptitle_size = 1, + subplot_titles_scale = 1, + subplot_margin_scale = rep(1, 4), brks = NULL, cols = NULL, drawleg = "S", @@ -153,6 +154,12 @@ be disregarded if no 'row_titles' are provided.} \item{subtitle_margin_scale}{Scale factor for the margins surrounding the subtitles. Takes 1 by default.} +\item{subplot_titles_scale}{Scale factor for the subplots top titles. Takes +1 by default.} + +\item{subplot_margin_scale}{Scale factor for the margins surrounding the +subplots, with the format c(y1, x1, y2, x2). Defaults to rep(1, 4).} + \item{brks, cols, bar_limits, triangle_ends}{Usually only providing 'brks' is enough to generate the desired colour bar. These parameters allow to define n breaks that define n - 1 intervals to classify each of the values -- GitLab From 62b19dbd7ce5343bbe9b4be8f20b9defc9acf79d Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Wed, 14 Sep 2022 12:39:51 +0200 Subject: [PATCH 3/3] Deleted subplots_margin_scale parameter and separated PlotSection --- R/PlotLayout.R | 18 +++++++----------- man/PlotLayout.Rd | 4 ---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/R/PlotLayout.R b/R/PlotLayout.R index 0b693a1..00ba674 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -103,8 +103,6 @@ #' subtitles. Takes 1 by default. #'@param subplot_titles_scale Scale factor for the subplots top titles. Takes #' 1 by default. -#'@param subplot_margin_scale Scale factor for the margins surrounding the -#' subplots, with the format c(y1, x1, y2, x2). Defaults to rep(1, 4). #'@param units Title at the top of the colour bar, most commonly the units of #' the variable provided in parameter 'var'. #'@param brks,cols,bar_limits,triangle_ends Usually only providing 'brks' is @@ -220,7 +218,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, title_scale = 1, title_margin_scale = 1, title_left_shift_scale = 1, subtitle_scale = 1, subtitle_margin_scale = 1, - subplot_titles_scale = 1, subplot_margin_scale = rep(1, 4), + subplot_titles_scale = 1, brks = NULL, cols = NULL, drawleg = 'S', titles = NULL, subsampleg = NULL, bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, col_sup = NULL, @@ -402,11 +400,6 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, stop("Parameter 'subplot_titles_scale' must be numeric.") } - # subplot_margin_scale - if (!is.numeric(subplot_margin_scale) || length(subplot_margin_scale) != 4) { - stop("Parameter 'subplot_margin_scale' must be a numeric vector with 4 elements.") - } - # Check titles if (!all(sapply(titles, is.character))) { stop("Parameter 'titles' must be a vector of character strings.") @@ -676,13 +669,16 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, fun_args <- c(list(y, toptitle = titles[plot_number]), list(...), special_args[[array_number]]) funct <- fun[[array_number]] - if (fun[[array_number]] %in% c('PlotEquiMap', 'PlotStereoMap', 'PlotSection')) { + if (fun[[array_number]] %in% c('PlotEquiMap', 'PlotStereoMap')) { fun_args <- c(fun_args, list(brks = colorbar$brks, cols = colorbar$cols, col_inf = colorbar$col_inf, col_sup = colorbar$col_sup, drawleg = FALSE, - title_scale = subplot_titles_scale, - margin_scale = subplot_margin_scale)) + title_scale = subplot_titles_scale)) + } else if (fun[[array_number]] == c('PlotSection')) { + fun_args <- c(fun_args, list(brks = colorbar$brks, cols = colorbar$cols, + drawleg = FALSE)) + } do.call(fun[[array_number]], fun_args) plot_number <<- plot_number + 1 diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index f634cfc..2a053ad 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -22,7 +22,6 @@ PlotLayout( subtitle_scale = 1, subtitle_margin_scale = 1, subplot_titles_scale = 1, - subplot_margin_scale = rep(1, 4), brks = NULL, cols = NULL, drawleg = "S", @@ -157,9 +156,6 @@ subtitles. Takes 1 by default.} \item{subplot_titles_scale}{Scale factor for the subplots top titles. Takes 1 by default.} -\item{subplot_margin_scale}{Scale factor for the margins surrounding the -subplots, with the format c(y1, x1, y2, x2). Defaults to rep(1, 4).} - \item{brks, cols, bar_limits, triangle_ends}{Usually only providing 'brks' is enough to generate the desired colour bar. These parameters allow to define n breaks that define n - 1 intervals to classify each of the values -- GitLab