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

add args to set axis titles #334

Merged
merged 6 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: see
Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2'
Version: 0.8.3.2
Version: 0.8.3.3
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -119,3 +119,4 @@ Config/Needs/website:
r-lib/pkgdown,
easystats/easystatstemplate
Config/rcmdcheck/ignore-inconsequential-notes: true
Remotes: easystats/performance
8 changes: 6 additions & 2 deletions R/plot.binned_residuals.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
plot.see_binned_residuals <- function(x,
size_line = 0.7,
size_point = 2.2,
size_title = 12,
size_axis_title = base_size,
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) {
Expand Down Expand Up @@ -108,7 +110,9 @@ 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.size = size_axis_title,
plot.title.size = size_title
)
}

Expand Down
10 changes: 9 additions & 1 deletion R/plot.check_collinearity.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ plot.see_check_collinearity <- function(x,
colors = c("#3aaf85", "#1b6ca8", "#cd201f"),
size_point = 3.5,
size_line = 0.8,
size_title = 12,
size_axis_title = base_size,
base_size = 10,
...) {
if (is.null(data)) {
Expand Down Expand Up @@ -52,6 +54,8 @@ plot.see_check_collinearity <- function(x,
dat,
size_point = size_point,
size_line = size_line,
size_title = size_title,
size_axis_title = size_axis_title,
base_size = base_size,
colors = colors,
ci_data = attributes(x)$CI,
Expand All @@ -64,6 +68,8 @@ plot.see_check_collinearity <- function(x,
size_point,
size_line,
theme_style = theme_lucid,
size_title = 12,
size_axis_title = 10,
base_size = 10,
colors = unname(social_colors(c("green", "blue", "red"))),
ci_data = NULL,
Expand Down Expand Up @@ -166,7 +172,9 @@ plot.see_check_collinearity <- function(x,
theme_style(
base_size = base_size,
plot.title.space = 3,
axis.title.space = 5
axis.title.space = 5,
plot.title.size = size_title,
axis.title.size = size_axis_title
) +
ggplot2::scale_y_continuous(
limits = c(1, ylim * 1.15),
Expand Down
19 changes: 17 additions & 2 deletions R/plot.check_heteroscedasticity.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @return A ggplot2-object.
#'
#' @seealso See also the vignette about [`check_model()`](https://easystats.github.io/performance/articles/check_model.html).

Check warning on line 11 in R/plot.check_heteroscedasticity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_heteroscedasticity.R,line=11,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.

Check warning on line 11 in R/plot.check_heteroscedasticity.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.check_heteroscedasticity.R,line=11,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.
#'
#' @examples
#' m <- lm(mpg ~ wt + cyl + gear + disp, data = mtcars)
Expand All @@ -16,7 +16,14 @@
#' result
#' plot(result, data = m) # data required for pkgdown
#' @export
plot.see_check_heteroscedasticity <- function(x, data = NULL, size_point = 2, size_line = 0.8, base_size = 10, ...) {
plot.see_check_heteroscedasticity <- function(x,
data = NULL,
size_point = 2,
size_line = 0.8,
size_title = 12,
size_axis_title = base_size,
base_size = 10,
...) {
if (is.null(data)) {
model <- .retrieve_data(x)
} else {
Expand Down Expand Up @@ -69,7 +76,15 @@
x = stats::fitted(model),
y = sqrt(abs(r))
)
.plot_diag_homogeneity(dat, size_point = size_point, size_line = size_line, base_size = base_size, ...)
.plot_diag_homogeneity(
dat,
size_point = size_point,
size_line = size_line,
base_size = base_size,
size_title = size_title,
size_axis_title = size_axis_title,
...
)
}


Expand Down
6 changes: 5 additions & 1 deletion R/plot.check_homogeneity.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ plot.see_check_homogeneity <- function(x, data = NULL, ...) {
size_line,
alpha_level = 0.2,
theme_style = theme_lucid,
size_title = 12,
size_axis_title = 10,
base_size = 10,
colors = unname(social_colors(c("green", "blue", "red"))),
dot_alpha_level = 0.8,
Expand Down Expand Up @@ -167,6 +169,8 @@ plot.see_check_homogeneity <- function(x, data = NULL, ...) {
theme_style(
base_size = base_size,
plot.title.space = 3,
axis.title.space = 5
axis.title.space = 5,
plot.title.size = size_title,
axis.title.size = size_axis_title
)
}
58 changes: 47 additions & 11 deletions R/plot.check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @return A ggplot2-object.
#'
#' @seealso See also the vignette about [`check_model()`](https://easystats.github.io/performance/articles/check_model.html).

Check warning on line 12 in R/plot.check_model.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_model.R,line=12,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.

Check warning on line 12 in R/plot.check_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.check_model.R,line=12,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.
#'
#' @examplesIf require("patchwork")
#' library(performance)
Expand All @@ -18,7 +18,7 @@
#' plot(check_model(model))
#'
#' @export
plot.see_check_model <- function(x,

Check warning on line 21 in R/plot.check_model.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_model.R,line=21,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 82 to at most 40.

Check warning on line 21 in R/plot.check_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.check_model.R,line=21,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 82 to at most 40.
style = theme_lucid,
colors = NULL,
type = c("density", "discrete_dots", "discrete_interval", "discrete_both"),
Expand All @@ -35,6 +35,8 @@
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")
size_title <- attr(x, "title_size")
alpha_level <- attr(x, "alpha")
dot_alpha_level <- attr(x, "dot_alpha")
show_dots <- attr(x, "show_dots")
Expand All @@ -44,7 +46,7 @@
plot_type <- attr(x, "type")
model_class <- attr(x, "model_class")

if (missing(type) && !is.null(plot_type) && plot_type %in% c("density", "discrete_dots", "discrete_interval", "discrete_both")) {

Check warning on line 49 in R/plot.check_model.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_model.R,line=49,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 131 characters.

Check warning on line 49 in R/plot.check_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.check_model.R,line=49,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 131 characters.
type <- plot_type
} else {
type <- match.arg(type)
Expand Down Expand Up @@ -79,6 +81,14 @@
base_size <- 10
}

if (is.null(size_axis_title)) {
size_axis_title <- base_size
}

if (is.null(size_title)) {
size_title <- 12
}

if (is.null(check)) {
check <- "all"
}
Expand All @@ -94,6 +104,8 @@
size_line = size_line,
size_point = size_point,
base_size = base_size,
size_axis_title = size_axis_title,
size_title = size_title,
type = type,
check_model = TRUE,
adjust_legend = TRUE,
Expand All @@ -104,11 +116,13 @@
if ("NCV" %in% names(x) && !is.null(x$NCV) && any(c("ncv", "linearity", "all") %in% check)) {
p$NCV <- .plot_diag_linearity(
x$NCV,
size_point,
size_line,
alpha_level,
size_point = size_point,
size_line = size_line,
alpha_level = alpha_level,
theme_style = style,
base_size = base_size,
size_axis_title = size_axis_title,
size_title = size_title,
colors = colors,
dot_alpha_level = dot_alpha_level,
show_dots = show_dots
Expand All @@ -121,6 +135,8 @@
x$BINNED_RESID,
style = style,
base_size = base_size,
size_axis_title = size_axis_title,
size_title = size_title,
colors = colors[c(2, 3, 1)],
adjust_legend = TRUE,
check_model = TRUE,
Expand All @@ -133,6 +149,8 @@
x$OVERDISPERSION,
style = style,
base_size = base_size,
size_axis_title = size_axis_title,
size_title = size_title,
colors = colors[c(1, 2)],
size_line = size_line,
type = overdisp_type
Expand All @@ -142,11 +160,13 @@
if ("HOMOGENEITY" %in% names(x) && !is.null(x$HOMOGENEITY) && any(c("homogeneity", "all") %in% check)) {
p$HOMOGENEITY <- .plot_diag_homogeneity(
x$HOMOGENEITY,
size_point,
size_line,
alpha_level,
size_point = size_point,
size_line = size_line,
alpha_level = alpha_level,
theme_style = style,
base_size = base_size,
size_axis_title = size_axis_title,
size_title = size_title,
colors = colors,
dot_alpha_level = dot_alpha_level,
show_dots = show_dots
Expand All @@ -161,6 +181,8 @@
size_line = size_line,
size_point = size_point,
theme_style = style,
size_axis_title = size_axis_title,
size_title = size_title,
base_size = base_size,
colors = colors,
dot_alpha_level = dot_alpha_level,
Expand All @@ -175,6 +197,8 @@
size_line = size_line,
theme_style = style,
base_size = base_size,
size_axis_title = size_axis_title,
size_title = size_title,
colors = colors,
ci_data = attributes(x$VIF)$CI,
is_check_model = TRUE
Expand All @@ -192,13 +216,17 @@
colors = colors,
detrend = detrend,
style = style,
base_size = base_size
base_size = base_size,
size_axis_title = size_axis_title,
size_title = size_title
)
} else {
p$QQ <- .plot_diag_qq(
x$QQ,
size_point,
size_line,
size_point = size_point,
size_line = size_line,
size_axis_title = size_axis_title,
size_title = size_title,
alpha_level = alpha_level,
detrend = detrend,
theme_style = style,
Expand All @@ -215,10 +243,12 @@
if ("NORM" %in% names(x) && !is.null(x$NORM) && any(c("normality", "all") %in% check)) {
p$NORM <- .plot_diag_norm(
x$NORM,
size_line,
size_line = size_line,
alpha_level = alpha_level,
theme_style = style,
base_size = base_size,
size_axis_title = size_axis_title,
size_title = size_title,
colors = colors
)
}
Expand All @@ -228,6 +258,8 @@
x$REQQ,
size_point,
size_line,
size_axis_title = size_axis_title,
size_title = size_title,
alpha_level = alpha_level,
theme_style = style,
base_size = base_size,
Expand All @@ -254,6 +286,8 @@
.plot_diag_linearity <- function(x,
size_point,
size_line,
size_axis_title = 10,
size_title = 12,
alpha_level = 0.2,
theme_style = theme_lucid,
base_size = 10,
Expand Down Expand Up @@ -290,6 +324,8 @@
theme_style(
base_size = base_size,
plot.title.space = 3,
axis.title.space = 5
axis.title.space = 5,
axis.title.size = size_axis_title,
plot.title.size = size_title
)
}
Loading
Loading