diff --git a/DESCRIPTION b/DESCRIPTION index 1ca05bb5d..0ee2994ee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: see Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2' -Version: 0.8.4.3 +Version: 0.8.4.4 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index 0aa08dc6a..0d14f6798 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# see 0.8.5 + +## Minor Changes + +* Improved scaling for detrended QQ plots when package *qqplotr* is not installed. + The normal and the detrended QQ plots are now visually more similar. + # see 0.8.4 ## Minor Changes diff --git a/R/plot.check_normality.R b/R/plot.check_normality.R index f3ceb9d50..dfb571cd2 100644 --- a/R/plot.check_normality.R +++ b/R/plot.check_normality.R @@ -276,6 +276,11 @@ plot.see_check_normality <- function(x, } else { insight::format_alert("For confidence bands, please install `qqplotr`.") + # to scale the detrended qq plot + N <- length(x$y) + SD <- stats::sd(x$y) * sqrt((N - 1) / N) + y_range <- round(range(x$y), 1) + gg_init <- ggplot2::ggplot(x, ggplot2::aes(sample = .data$y)) qq_stuff <- list( @@ -294,13 +299,19 @@ plot.see_check_normality <- function(x, ) }, ggplot2::geom_qq( - mapping = if (detrend) ggplot2::aes(y = ggplot2::after_stat(.data$sample) - ggplot2::after_stat(.data$theoretical)), + mapping = if (detrend) ggplot2::aes( + x = ggplot2::after_stat(.data$theoretical * SD), + y = ggplot2::after_stat(.data$sample - .data$theoretical * SD) + ), shape = 16, na.rm = TRUE, stroke = 0, size = size_point, colour = colors[2] - ) + ), + if (detrend) { + ggplot2::ylim(y_range) + } ) if (detrend) {