diff --git a/R/regressionlinear.R b/R/regressionlinear.R
index e0cc745a..056f1c81 100755
--- a/R/regressionlinear.R
+++ b/R/regressionlinear.R
@@ -2123,7 +2123,7 @@ RegressionLinearInternal <- function(jaspResults, dataset = NULL, options) {
mapping = ggplot2::aes(x = x, y = y, group = group),
size = 1) +
ggplot2::xlab(xlab) +
- ggplot2::ylab(ylab)
+ ggplot2::ylab(ylab)
factorPoints <- jaspGraphs::geom_point(data = d_factor,
mapping = ggplot2::aes(x = x, y = y))
@@ -2131,12 +2131,15 @@ RegressionLinearInternal <- function(jaspResults, dataset = NULL, options) {
} else {
+ xBreaks <- jaspGraphs::getPrettyAxisBreaks(xVar)
+
basicMarginalPlot <- ggplot2::ggplot() +
ggplot2::geom_line(data = d,
mapping = ggplot2::aes(x = x, y = y),
size = 1) +
ggplot2::xlab(xlab) +
ggplot2::ylab(ylab) +
+ ggplot2::scale_x_continuous(breaks = xBreaks, limits = range(xBreaks)) +
ggplot2::geom_rug(data = d,
mapping = ggplot2::aes(x = x, y = y),
sides = "b",
@@ -2144,7 +2147,6 @@ RegressionLinearInternal <- function(jaspResults, dataset = NULL, options) {
factorPoints <- NULL
}
-
if (!is.null(conf_min)) {
d <- cbind(d, conf_lower = conf_min, conf_upper = conf_max)
if (is.factor(xVar)) {
@@ -2196,13 +2198,17 @@ RegressionLinearInternal <- function(jaspResults, dataset = NULL, options) {
predictionBounds <- predictionBound1 <- predictionBound2 <- NULL
}
+ # base y-axis breaks on y and the prediction and/or confidence interval
+ yBreaks <- jaspGraphs::getPrettyAxisBreaks(jaspGraphs::getPrettyAxisBreaks(unlist(d[, -1])))
+
finalMarginalPlot <- basicMarginalPlot +
confidenceBounds +
predictionBound1 +
predictionBound2 +
factorPoints +
jaspGraphs::geom_rangeframe() +
- jaspGraphs::themeJaspRaw(axis.title.cex = 1.2)
+ jaspGraphs::themeJaspRaw(axis.title.cex = 1.2) +
+ ggplot2::scale_y_continuous(breaks = yBreaks, limits = range(yBreaks))
return(finalMarginalPlot)
}
diff --git a/tests/testthat/_snaps/regressionlinear/marginal-effect-of-contcor1-on-contnormal.svg b/tests/testthat/_snaps/regressionlinear/marginal-effect-of-contcor1-on-contnormal.svg
index ff5eb4ba..aaa142c0 100644
--- a/tests/testthat/_snaps/regressionlinear/marginal-effect-of-contcor1-on-contnormal.svg
+++ b/tests/testthat/_snaps/regressionlinear/marginal-effect-of-contcor1-on-contnormal.svg
@@ -27,132 +27,138 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--0.4
--0.2
-0.0
-0.2
-
-
-
-
+-0.6
+-0.4
+-0.2
+0.0
+0.2
+
+
+
+
+
-
-
-
-
-
--2
--1
-0
-1
-2
+
+
+
+
+
+
+
+-3
+-2
+-1
+0
+1
+2
+3
contcor1
contNormal
marginal-effect-of-contcor1-on-contnormal
diff --git a/tests/testthat/_snaps/regressionlinear/marginal-effect-of-contgamma-on-contnormal.svg b/tests/testthat/_snaps/regressionlinear/marginal-effect-of-contgamma-on-contnormal.svg
index 34545dcb..00b7bcb9 100644
--- a/tests/testthat/_snaps/regressionlinear/marginal-effect-of-contgamma-on-contnormal.svg
+++ b/tests/testthat/_snaps/regressionlinear/marginal-effect-of-contgamma-on-contnormal.svg
@@ -27,134 +27,140 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--0.40
--0.35
--0.30
--0.25
--0.20
--0.15
-
-
-
-
-
-
+-0.40
+-0.35
+-0.30
+-0.25
+-0.20
+-0.15
+-0.10
+
+
+
+
+
+
+
-
-
-
-
-0.0
-2.5
-5.0
-7.5
+
+
+
+
+
+
+0
+2
+4
+6
+8
+10
contGamma
contNormal
marginal-effect-of-contgamma-on-contnormal
diff --git a/tests/testthat/_snaps/regressionlinear/marginal-plot.svg b/tests/testthat/_snaps/regressionlinear/marginal-plot.svg
index 502f2ba2..2493cd04 100644
--- a/tests/testthat/_snaps/regressionlinear/marginal-plot.svg
+++ b/tests/testthat/_snaps/regressionlinear/marginal-plot.svg
@@ -27,139 +27,147 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--2
--1
-0
-1
-2
-
-
-
-
-
+-3
+-2
+-1
+0
+1
+2
+3
+
+
+
+
+
+
+
-
-
-
-
-
--2
--1
-0
-1
-2
+
+
+
+
+
+
+
+-3
+-2
+-1
+0
+1
+2
+3
contcor1
contNormal
marginal-plot