Skip to content

Commit

Permalink
add args to set axis titles (#334)
Browse files Browse the repository at this point in the history
* add args to set axis titles

* version

* fix

* more args

* fix

* fix
  • Loading branch information
strengejacke committed Mar 27, 2024
1 parent 80daa3c commit 1a090e1
Show file tree
Hide file tree
Showing 20 changed files with 683 additions and 130 deletions.
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 @@ -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 @@ plot.see_check_heteroscedasticity <- function(x, data = NULL, size_point = 2, si
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 @@ -35,6 +35,8 @@ plot.see_check_model <- function(x,
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 Down Expand Up @@ -79,6 +81,14 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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 @@ plot.see_check_model <- function(x,
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.see_check_model <- function(x,
.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 @@ plot.see_check_model <- function(x,
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

0 comments on commit 1a090e1

Please sign in to comment.