Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add show_regressionline (or similar) #629

Open
roaldarbol opened this issue Jan 18, 2025 · 0 comments
Open

Feature request: Add show_regressionline (or similar) #629

roaldarbol opened this issue Jan 18, 2025 · 0 comments

Comments

@roaldarbol
Copy link

roaldarbol commented Jan 18, 2025

In some fields, regression lines on point plots are only added when a regression coefficient is significant. In those cases it would be great to have a way to still plot the residuals (with show_residuals=TRUE), turn off the confidence interval (show_ci=FALSE), and also disable plotting the regression line itself (so show_regressionline/show_line or something along those lines).

I've tried to get to the residuals myself (also mentioned in #627) which would allow me to make a plot myself, but have not been successful until now.


Have found a temporary solution, which is to set the layer to NULL:

library(ggeffects)
data("mtcars")
lm_c <- lm(hp ~ wt + vs, data = mtcars)
c_pred <- predict_response(lm_c, "wt")
p_c <- plot(c_pred, show_residuals = TRUE, show_ci = FALSE)
#> Data points may overlap. Use the `jitter` argument to add some amount of
#>   random variation to the location of data points and avoid overplotting.
p_c$layers[[2]] <- NULL
p_c

Created on 2025-01-18 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant