From 48566953c48e96a2de2496052c5d0dd952ef2252 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 9 Jul 2026 12:17:48 +0200 Subject: [PATCH 1/2] The ggplot2 argument is linewidth -- should we instead go in the other direction to be consistent with the core plotting framework? Fixes #452 --- DESCRIPTION | 2 +- NEWS.md | 5 +++-- R/plot.binned_residuals.R | 5 +++++ R/plot.check_collinearity.R | 6 ++++++ R/plot.check_heteroscedasticity.R | 6 ++++++ R/plot.check_model.R | 5 +++++ R/plot.check_normality.R | 9 ++++++++- R/plot.check_outliers.R | 6 ++++++ R/plot.check_overdisp.R | 6 ++++++ R/plot.check_predictions.R | 12 ++++++++++++ R/plot.compare_performance.R | 6 ++++++ R/plot.estimate_density.R | 6 ++++++ R/plot.p_function.R | 6 ++++++ R/plot.parameters_brms_meta.R | 6 ++++++ R/plot.parameters_simulate.R | 7 +++++++ R/plot.performance_simres.R | 6 ++++++ man/plot.see_check_collinearity.Rd | 3 ++- man/plot.see_check_heteroscedasticity.Rd | 3 ++- man/plot.see_check_normality.Rd | 3 ++- man/plot.see_check_outliers.Rd | 3 ++- man/plot.see_compare_performance.Rd | 3 ++- man/plot.see_estimate_density.Rd | 3 ++- man/plot.see_p_function.Rd | 3 ++- man/plot.see_parameters_brms_meta.Rd | 3 ++- man/plot.see_parameters_simulate.Rd | 3 ++- man/plot.see_performance_simres.Rd | 3 ++- man/print.see_performance_pp_check.Rd | 3 ++- tests/testthat/test-vdiffr_check_predictions.R | 10 ++++++++++ 28 files changed, 127 insertions(+), 15 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 28c5cd375..a456a5c36 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: see Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2' -Version: 0.14.1.1 +Version: 0.14.1.2 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index fe0ecf8a3..51d177089 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,10 @@ # see (devel) -## Breaking Changes +## Changes * Argument `linewidth` was renamed to `size_line`, to be consistent across the - easystats-ecosystem. + easystats-ecosystem. However, `linewidth` remains as an alias, since this is + the name of the corresponding ggplot2-argument. # see 0.14.1 diff --git a/R/plot.binned_residuals.R b/R/plot.binned_residuals.R index 4da70274a..cabb1121f 100644 --- a/R/plot.binned_residuals.R +++ b/R/plot.binned_residuals.R @@ -28,6 +28,11 @@ plot.see_binned_residuals <- function( } dots <- list(...) + # handle alias + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + # set defaults term <- attr(x, "term", exact = TRUE) if (is.null(dots[["show_dots"]])) { diff --git a/R/plot.check_collinearity.R b/R/plot.check_collinearity.R index d934427a8..27204c819 100644 --- a/R/plot.check_collinearity.R +++ b/R/plot.check_collinearity.R @@ -38,6 +38,12 @@ plot.see_check_collinearity <- function( return(NULL) } + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + dat$group <- "low" dat$group[dat$VIF >= 5 & dat$VIF < 10] <- "moderate" dat$group[dat$VIF >= 10] <- "high" diff --git a/R/plot.check_heteroscedasticity.R b/R/plot.check_heteroscedasticity.R index f4ca06ab6..2aba8b068 100644 --- a/R/plot.check_heteroscedasticity.R +++ b/R/plot.check_heteroscedasticity.R @@ -34,6 +34,12 @@ plot.see_check_heteroscedasticity <- function( model <- data } + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + faminfo <- insight::model_info(model) r <- tryCatch( if (inherits(model, "merMod")) { diff --git a/R/plot.check_model.R b/R/plot.check_model.R index 04da9c9c9..4f80026e0 100644 --- a/R/plot.check_model.R +++ b/R/plot.check_model.R @@ -54,6 +54,11 @@ plot.see_check_model <- function( show_dots <- .default_value(x, "show_dots", TRUE) ppc_range <- .default_value(x, "ppc_range") + # handle alias + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + # Check for Confidence Intervals: Backwards compatibility for older package # versions show_ci <- !isFALSE(attr(x, "show_ci")) diff --git a/R/plot.check_normality.R b/R/plot.check_normality.R index 7432deb85..5d3625875 100644 --- a/R/plot.check_normality.R +++ b/R/plot.check_normality.R @@ -7,7 +7,8 @@ #' Options are `"qq"` (default) for quantile-quantile (Q-Q) plots, #' `"pp"` for probability-probability (P-P) plots, or #' `"density"` for density overlay plots. -#' @param size_line Numeric value specifying size of line geoms. +#' @param size_line Numeric value specifying size of line geoms. `linewidth` is +#' an alias for `size_line`. #' @param alpha_dot Numeric value specifying alpha level of the point geoms. #' @param alpha Numeric value specifying alpha level of the confidence bands. #' @param colors Character vector of length two, indicating the colors (in @@ -65,6 +66,12 @@ plot.see_check_normality <- function( model <- data } + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + # for GLM, only halfnormal Q-Q plots if (inherits(model, "glm")) { type <- "qq" diff --git a/R/plot.check_outliers.R b/R/plot.check_outliers.R index 58fc19141..0d2c28539 100644 --- a/R/plot.check_outliers.R +++ b/R/plot.check_outliers.R @@ -82,6 +82,12 @@ plot.see_check_outliers <- function( # depending on the method outlier_methods <- attr(x, "method", exact = TRUE) + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + # validate that the method is correct if (length(outlier_methods) == 0) { insight::format_error( diff --git a/R/plot.check_overdisp.R b/R/plot.check_overdisp.R index ace204c88..aa60d75bf 100644 --- a/R/plot.check_overdisp.R +++ b/R/plot.check_overdisp.R @@ -10,6 +10,12 @@ plot.see_check_overdisp <- function( type = 1, ... ) { + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + .plot_diag_overdispersion( x, theme = theme, diff --git a/R/plot.check_predictions.R b/R/plot.check_predictions.R index 3904a2dcf..352720b12 100644 --- a/R/plot.check_predictions.R +++ b/R/plot.check_predictions.R @@ -132,6 +132,12 @@ print.see_performance_pp_check <- function( orig_x <- x check_range <- isTRUE(attributes(x)$check_range) + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + p1 <- .prepare_pp_check( x, size_line = size_line, @@ -181,6 +187,12 @@ plot.see_performance_pp_check <- function( x_limits <- .default_value(x, "x_limits", x_limits) type <- .default_value(x, "type", type) + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + p1 <- .prepare_pp_check( x, size_line = size_line, diff --git a/R/plot.compare_performance.R b/R/plot.compare_performance.R index 2a451a9cf..3616a1c02 100644 --- a/R/plot.compare_performance.R +++ b/R/plot.compare_performance.R @@ -97,6 +97,12 @@ plot.see_compare_performance <- function(x, size_line = 1, ...) { x <- data_plot(x) } + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + p <- ggplot2::ggplot( x, ggplot2::aes( diff --git a/R/plot.estimate_density.R b/R/plot.estimate_density.R index fc146e66f..32c275379 100644 --- a/R/plot.estimate_density.R +++ b/R/plot.estimate_density.R @@ -178,6 +178,12 @@ plot.see_estimate_density <- function( } ) + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + if (!inherits(x, "data_plot")) { x <- data_plot(x, data = model, centrality = centrality, ci = ci, ...) } diff --git a/R/plot.p_function.R b/R/plot.p_function.R index 7f1aba2b3..43e611c13 100644 --- a/R/plot.p_function.R +++ b/R/plot.p_function.R @@ -44,6 +44,12 @@ plot.see_p_function <- function( # data for vertical CI level lines data_ci_segments <- x + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + # remove intercept? data_ribbon <- .remove_intercept(data_ribbon, show_intercept = show_intercept) data_ci_segments <- .remove_intercept( diff --git a/R/plot.parameters_brms_meta.R b/R/plot.parameters_brms_meta.R index 5d9ee36a1..d791b65f2 100644 --- a/R/plot.parameters_brms_meta.R +++ b/R/plot.parameters_brms_meta.R @@ -169,6 +169,12 @@ plot.see_parameters_brms_meta <- function( } ) + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + if (!inherits(x, "data_plot")) { x <- data_plot(x, data = model, normalize_height = normalize_height, ...) } diff --git a/R/plot.parameters_simulate.R b/R/plot.parameters_simulate.R index c48745b13..93915b005 100644 --- a/R/plot.parameters_simulate.R +++ b/R/plot.parameters_simulate.R @@ -109,10 +109,17 @@ plot.see_parameters_simulate <- function( ) { is_mlm <- !is.null(attributes(x)$object_class) && "mlm" %in% attributes(x)$object_class + if (is.null(n_columns) && (isTRUE(is_mlm) || "Response" %in% colnames(x))) { n_columns <- 1 } + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + # check for defaults if (missing(centrality) && !is.null(attributes(x)$centrality)) { centrality <- attributes(x)$centrality diff --git a/R/plot.performance_simres.R b/R/plot.performance_simres.R index 8c0e769f8..29dac3058 100644 --- a/R/plot.performance_simres.R +++ b/R/plot.performance_simres.R @@ -49,6 +49,12 @@ plot.see_performance_simres <- function( insight::check_if_installed("DHARMa") qqplotr_installed <- insight::check_if_installed("qqplotr", quietly = TRUE) + # handle alias + dots <- list(...) + if (!is.null(dots[["linewidth"]])) { + size_line <- dots[["linewidth"]] + } + theme <- .set_default_theme( x, theme, diff --git a/man/plot.see_check_collinearity.Rd b/man/plot.see_check_collinearity.Rd index f7a05e69a..f77498cdf 100644 --- a/man/plot.see_check_collinearity.Rd +++ b/man/plot.see_check_collinearity.Rd @@ -31,7 +31,8 @@ hex-format) for points and line.} \item{size_point}{Numeric specifying size of point-geoms.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{base_size, size_axis_title, size_title}{Numeric value specifying size of axis and plot titles.} diff --git a/man/plot.see_check_heteroscedasticity.Rd b/man/plot.see_check_heteroscedasticity.Rd index b107e7a6c..07b6b464f 100644 --- a/man/plot.see_check_heteroscedasticity.Rd +++ b/man/plot.see_check_heteroscedasticity.Rd @@ -24,7 +24,8 @@ statistical model.} \item{size_point}{Numeric specifying size of point-geoms.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{base_size, size_axis_title, size_title}{Numeric value specifying size of axis and plot titles.} diff --git a/man/plot.see_check_normality.Rd b/man/plot.see_check_normality.Rd index 78ec8a218..288a2fa58 100644 --- a/man/plot.see_check_normality.Rd +++ b/man/plot.see_check_normality.Rd @@ -33,7 +33,8 @@ Options are \code{"qq"} (default) for quantile-quantile (Q-Q) plots, \item{data}{The original data used to create this object. Can be a statistical model.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{size_point}{Numeric specifying size of point-geoms.} diff --git a/man/plot.see_check_outliers.Rd b/man/plot.see_check_outliers.Rd index d65b07922..cbeb4e612 100644 --- a/man/plot.see_check_outliers.Rd +++ b/man/plot.see_check_outliers.Rd @@ -27,7 +27,8 @@ \item{size_text}{Numeric value specifying size of text labels.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{base_size, size_axis_title, size_title}{Numeric value specifying size of axis and plot titles.} diff --git a/man/plot.see_compare_performance.Rd b/man/plot.see_compare_performance.Rd index 351e46ebf..60040fbfe 100644 --- a/man/plot.see_compare_performance.Rd +++ b/man/plot.see_compare_performance.Rd @@ -9,7 +9,8 @@ \arguments{ \item{x}{An object.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{...}{Arguments passed to or from other methods.} } diff --git a/man/plot.see_estimate_density.Rd b/man/plot.see_estimate_density.Rd index f8e95a4c8..158f1a96c 100644 --- a/man/plot.see_estimate_density.Rd +++ b/man/plot.see_estimate_density.Rd @@ -45,7 +45,8 @@ distributions.} \item{alpha_posteriors}{Numeric value specifying alpha for the posterior distributions.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{size_point}{Numeric specifying size of point-geoms.} diff --git a/man/plot.see_p_function.Rd b/man/plot.see_p_function.Rd index 21ea69dec..a82636bd3 100644 --- a/man/plot.see_p_function.Rd +++ b/man/plot.see_p_function.Rd @@ -26,7 +26,8 @@ are plotted as facets.} \item{size_point}{Numeric specifying size of point-geoms.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{size_text}{Numeric value specifying size of text labels.} diff --git a/man/plot.see_parameters_brms_meta.Rd b/man/plot.see_parameters_brms_meta.Rd index 904511d2b..2f100ff00 100644 --- a/man/plot.see_parameters_brms_meta.Rd +++ b/man/plot.see_parameters_brms_meta.Rd @@ -22,7 +22,8 @@ \item{size_point}{Numeric specifying size of point-geoms.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{size_text}{Numeric value specifying size of text labels.} diff --git a/man/plot.see_parameters_simulate.Rd b/man/plot.see_parameters_simulate.Rd index d91542623..b682b3d2b 100644 --- a/man/plot.see_parameters_simulate.Rd +++ b/man/plot.see_parameters_simulate.Rd @@ -43,7 +43,8 @@ distribution of simulated draws is narrow for some parameters, this may result in very flat density-areas. In such cases, set \code{normalize_height = FALSE}.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{alpha_posteriors}{Numeric value specifying alpha for the posterior distributions.} diff --git a/man/plot.see_performance_simres.Rd b/man/plot.see_performance_simres.Rd index a48d4d136..d22859f3a 100644 --- a/man/plot.see_performance_simres.Rd +++ b/man/plot.see_performance_simres.Rd @@ -23,7 +23,8 @@ \arguments{ \item{x}{An object.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{size_point}{Numeric specifying size of point-geoms.} diff --git a/man/print.see_performance_pp_check.Rd b/man/print.see_performance_pp_check.Rd index 5e73c963a..4657890a2 100644 --- a/man/print.see_performance_pp_check.Rd +++ b/man/print.see_performance_pp_check.Rd @@ -40,7 +40,8 @@ \arguments{ \item{x}{An object.} -\item{size_line}{Numeric value specifying size of line geoms.} +\item{size_line}{Numeric value specifying size of line geoms. \code{linewidth} is +an alias for \code{size_line}.} \item{size_point}{Numeric specifying size of point-geoms.} diff --git a/tests/testthat/test-vdiffr_check_predictions.R b/tests/testthat/test-vdiffr_check_predictions.R index 28d713d4f..ae71db36b 100644 --- a/tests/testthat/test-vdiffr_check_predictions.R +++ b/tests/testthat/test-vdiffr_check_predictions.R @@ -26,6 +26,16 @@ test_that("plot.see_check_predictions() renders correctly", { title = "check_predictions_with_range", fig = plot(performance::check_predictions(model, check_range = TRUE)) ) + + expect_doppelganger_with_seed( + title = "check_predictions_size_line", + fig = plot(performance::check_predictions(model), size_line = 2) + ) + + expect_doppelganger_with_seed( + title = "check_predictions_linewidth", + fig = plot(performance::check_predictions(model), linewidth = 2) + ) }) From adff1d7ab62f442b5b03992f59c0b8abdf9a8358 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 9 Jul 2026 12:20:09 +0200 Subject: [PATCH 2/2] add snaps --- .../check-predictions-linewidth.svg | 114 ++++++++++++++++++ .../check-predictions-size-line.svg | 114 ++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 tests/testthat/_snaps/vdiffr_check_predictions/check-predictions-linewidth.svg create mode 100644 tests/testthat/_snaps/vdiffr_check_predictions/check-predictions-size-line.svg diff --git a/tests/testthat/_snaps/vdiffr_check_predictions/check-predictions-linewidth.svg b/tests/testthat/_snaps/vdiffr_check_predictions/check-predictions-linewidth.svg new file mode 100644 index 000000000..9626d6193 --- /dev/null +++ b/tests/testthat/_snaps/vdiffr_check_predictions/check-predictions-linewidth.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.00 +0.02 +0.04 +0.06 +0.08 + + + + + + + + + +0 +10 +20 +30 +mpg +Density + + + + + +Observed data +Model-predicted data +Model-predicted lines should resemble observed data line +Posterior Predictive Check + + diff --git a/tests/testthat/_snaps/vdiffr_check_predictions/check-predictions-size-line.svg b/tests/testthat/_snaps/vdiffr_check_predictions/check-predictions-size-line.svg new file mode 100644 index 000000000..9626d6193 --- /dev/null +++ b/tests/testthat/_snaps/vdiffr_check_predictions/check-predictions-size-line.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.00 +0.02 +0.04 +0.06 +0.08 + + + + + + + + + +0 +10 +20 +30 +mpg +Density + + + + + +Observed data +Model-predicted data +Model-predicted lines should resemble observed data line +Posterior Predictive Check + +