From e84396511f10f6b317b92e859d4c68afbdb09b09 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 27 Mar 2024 08:16:49 +0100 Subject: [PATCH] add args to set axis titles --- R/plot.binned_residuals.R | 6 ++++-- R/plot.check_model.R | 12 +++++++++++- R/plot.check_normality.R | 1 + R/plot.check_predictions.R | 25 +++++++++++++++++++------ man/plot.see_check_normality.Rd | 2 ++ man/print.see_performance_pp_check.Rd | 11 ++++++++--- 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/R/plot.binned_residuals.R b/R/plot.binned_residuals.R index 5a098a534..7c62b7ae7 100644 --- a/R/plot.binned_residuals.R +++ b/R/plot.binned_residuals.R @@ -2,10 +2,11 @@ plot.see_binned_residuals <- function(x, size_line = 0.7, size_point = 2.2, + size_axis_title = base_size * 0.8, + base_size = 10, colors = social_colors(c("blue", "red", "green")), show_smooth = FALSE, style = theme_lucid, - base_size = 10, ...) { x$se.lo <- -x$se if (length(unique(x$group)) > 1L) { @@ -108,7 +109,8 @@ plot.see_binned_residuals <- function(x, p <- p + theme_style( base_size = base_size, plot.title.space = 3, - axis.title.space = 5 + axis.title.space = 5, + axis.title = ggplot2::element_text(size = size_axis_title) ) } diff --git a/R/plot.check_model.R b/R/plot.check_model.R index eb5e101c2..0b60bef6e 100644 --- a/R/plot.check_model.R +++ b/R/plot.check_model.R @@ -35,6 +35,7 @@ plot.see_check_model <- function(x, show_labels <- attr(x, "show_labels") %||% TRUE size_text <- attr(x, "text_size") base_size <- attr(x, "base_size") + size_axis_title <- attr(x, "axis_title_size") alpha_level <- attr(x, "alpha") dot_alpha_level <- attr(x, "dot_alpha") show_dots <- attr(x, "show_dots") @@ -79,6 +80,10 @@ plot.see_check_model <- function(x, base_size <- 10 } + if (is.null(size_axis_title)) { + size_axis_title <- base_size * 0.8 + } + if (is.null(check)) { check <- "all" } @@ -94,6 +99,7 @@ plot.see_check_model <- function(x, size_line = size_line, size_point = size_point, base_size = base_size, + size_axis_title = size_axis_title, type = type, check_model = TRUE, adjust_legend = TRUE, @@ -109,6 +115,7 @@ plot.see_check_model <- function(x, alpha_level, theme_style = style, base_size = base_size, + size_axis_title = size_axis_title, colors = colors, dot_alpha_level = dot_alpha_level, show_dots = show_dots @@ -121,6 +128,7 @@ plot.see_check_model <- function(x, x$BINNED_RESID, style = style, base_size = base_size, + size_axis_title = size_axis_title, colors = colors[c(2, 3, 1)], adjust_legend = TRUE, check_model = TRUE, @@ -254,6 +262,7 @@ plot.see_check_model <- function(x, .plot_diag_linearity <- function(x, size_point, size_line, + size_axis_title = 8, alpha_level = 0.2, theme_style = theme_lucid, base_size = 10, @@ -290,6 +299,7 @@ plot.see_check_model <- function(x, theme_style( base_size = base_size, plot.title.space = 3, - axis.title.space = 5 + axis.title.space = 5, + axis.title = ggplot2::element_text(size = size_axis_title) ) } diff --git a/R/plot.check_normality.R b/R/plot.check_normality.R index abdd20e0d..86868edac 100644 --- a/R/plot.check_normality.R +++ b/R/plot.check_normality.R @@ -20,6 +20,7 @@ #' `"ks"` or `"ts"` for simultaneous testing. See `qqplotr::stat_qq_band()` #' for details. #' @param base_size Base font size for plots. +#' @param size_axis_title Numeric value specifying size of axis titles. #' @inheritParams data_plot #' @inheritParams plot.see_bayesfactor_parameters #' diff --git a/R/plot.check_predictions.R b/R/plot.check_predictions.R index 780fe8173..a2564f142 100644 --- a/R/plot.check_predictions.R +++ b/R/plot.check_predictions.R @@ -77,7 +77,9 @@ print.see_performance_pp_check <- function(x, size_point = 2, line_alpha = 0.15, size_bar = 0.7, + size_axis_title = base_size * 0.8, style = theme_lucid, + base_size = 10, colors = unname(social_colors(c("green", "blue"))), type = c("density", "discrete_dots", "discrete_interval", "discrete_both"), x_limits = NULL, @@ -103,6 +105,7 @@ print.see_performance_pp_check <- function(x, line_alpha, theme_style = style, colors = colors, + base_size = base_size, type = type, x_limits = x_limits, ... @@ -124,8 +127,9 @@ print.see_performance_pp_check <- function(x, plot.see_performance_pp_check <- function(x, size_line = 0.5, size_point = 2, - line_alpha = 0.15, size_bar = 0.7, + size_axis_title = base_size * 0.8, + line_alpha = 0.15, style = theme_lucid, base_size = 10, colors = unname(social_colors(c("green", "blue"))), @@ -148,11 +152,12 @@ plot.see_performance_pp_check <- function(x, p1 <- .plot_pp_check( x, - size_line, - size_point, - line_alpha, + size_line = size_line, + size_point = size_point, + line_alpha = line_alpha, theme_style = style, base_size = base_size, + size_axis_title = size_axis_title, colors = colors, type = type, x_limits = x_limits, @@ -175,6 +180,7 @@ plot.see_performance_pp_check <- function(x, line_alpha, theme_style, base_size = 10, + size_axis_title = 8, colors, type = "density", x_limits = NULL, @@ -209,7 +215,8 @@ plot.see_performance_pp_check <- function(x, out <- out + theme_style( base_size = base_size, plot.title.space = 3, - axis.title.space = 5 + axis.title.space = 5, + axis.title = ggplot2::element_text(size = size_axis_title) ) } @@ -229,7 +236,13 @@ plot.see_performance_pp_check <- function(x, } -.plot_check_predictions_density <- function(x, colors, info, size_line, line_alpha, bandwidth, ...) { +.plot_check_predictions_density <- function(x, + colors, + info, + size_line, + line_alpha, + bandwidth, + ...) { ggplot2::ggplot(x) + ggplot2::stat_density( mapping = ggplot2::aes( diff --git a/man/plot.see_check_normality.Rd b/man/plot.see_check_normality.Rd index e95dbe292..b7b6552e6 100644 --- a/man/plot.see_check_normality.Rd +++ b/man/plot.see_check_normality.Rd @@ -53,6 +53,8 @@ be one of \code{"pointwise"} or \code{"boot"} for pointwise confidence bands, or for details.} \item{...}{Arguments passed to or from other methods.} + +\item{size_axis_title}{Numeric value specifying size of axis titles.} } \value{ A ggplot2-object. diff --git a/man/print.see_performance_pp_check.Rd b/man/print.see_performance_pp_check.Rd index 145105781..c03506575 100644 --- a/man/print.see_performance_pp_check.Rd +++ b/man/print.see_performance_pp_check.Rd @@ -11,7 +11,9 @@ size_point = 2, line_alpha = 0.15, size_bar = 0.7, + size_axis_title = base_size * 0.8, style = theme_lucid, + base_size = 10, colors = unname(social_colors(c("green", "blue"))), type = c("density", "discrete_dots", "discrete_interval", "discrete_both"), x_limits = NULL, @@ -22,8 +24,9 @@ x, size_line = 0.5, size_point = 2, - line_alpha = 0.15, size_bar = 0.7, + size_axis_title = base_size * 0.8, + line_alpha = 0.15, style = theme_lucid, base_size = 10, colors = unname(social_colors(c("green", "blue"))), @@ -43,8 +46,12 @@ \item{size_bar}{Size of bar geoms.} +\item{size_axis_title}{Numeric value specifying size of axis titles.} + \item{style}{A ggplot2-theme.} +\item{base_size}{Base font size for plots.} + \item{colors}{Character vector of length two, indicating the colors (in hex-format) for points and line.} @@ -57,8 +64,6 @@ or ordinal etc. - outcomes).} If not \code{NULL}, will zoom in the x-axis to the specified limits.} \item{...}{Arguments passed to or from other methods.} - -\item{base_size}{Base font size for plots.} } \value{ A ggplot2-object.