Skip to content

Commit

Permalink
Harmonize API (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil authored Dec 1, 2024
1 parent 8286345 commit f8baf90
Show file tree
Hide file tree
Showing 55 changed files with 346 additions and 343 deletions.
12 changes: 6 additions & 6 deletions R/plot.bayesfactor_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#' The `plot()` method for the `bayestestR::bayesfactor_parameters()` function.
#'
#' @param size_point Numeric specifying size of point-geoms.
#' @param rope_alpha Numeric specifying transparency level of ROPE ribbon.
#' @param rope_color Character specifying color of ROPE ribbon.
#' @param alpha_rope Numeric specifying transparency level of ROPE ribbon.
#' @param color_rope Character specifying color of ROPE ribbon.
#' @param show_intercept Logical, if `TRUE`, the intercept-parameter is included
#' in the plot. By default, it is hidden because in many cases the
#' intercept-parameter has a posterior distribution on a very different
Expand All @@ -19,8 +19,8 @@
#' @export
plot.see_bayesfactor_parameters <- function(x,
size_point = 2,
rope_color = "#0171D3",
rope_alpha = 0.2,
color_rope = "#0171D3",
alpha_rope = 0.2,
show_intercept = FALSE,
...) {
if ("log_BF" %in% names(x) && !"BF" %in% names(x)) {
Expand Down Expand Up @@ -80,8 +80,8 @@ plot.see_bayesfactor_parameters <- function(x,
xmax = rope[2],
ymin = 0,
ymax = Inf,
fill = rope_color,
alpha = rope_alpha
fill = color_rope,
alpha = alpha_rope
)
} else {
p <- p +
Expand Down
8 changes: 4 additions & 4 deletions R/plot.binned_residuals.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @export
plot.see_binned_residuals <- function(x,
size_line = 0.7,
linewidth = 0.7,
size_point = 2.2,
size_title = 12,
size_axis_title = base_size,
Expand Down Expand Up @@ -62,7 +62,7 @@ plot.see_binned_residuals <- function(x,
se = FALSE,
formula = y ~ s(x, bs = "tp"),
colour = colors[3],
linewidth = size_line
linewidth = linewidth
)
}

Expand All @@ -89,7 +89,7 @@ plot.see_binned_residuals <- function(x,
ggplot2::geom_point(ggplot2::aes(y = .data$ybar), size = size_point) +
ggplot2::geom_errorbar(
ggplot2::aes(ymin = .data$CI_low, ymax = .data$CI_high),
linewidth = size_line,
linewidth = linewidth,
width = 0
)
} else {
Expand All @@ -101,7 +101,7 @@ plot.see_binned_residuals <- function(x,
ymax = .data$CI_high,
colour = .data$group
),
linewidth = size_line,
linewidth = linewidth,
width = 0
)
}
Expand Down
8 changes: 4 additions & 4 deletions R/plot.check_collinearity.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plot.see_check_collinearity <- function(x,
data = NULL,
colors = c("#3aaf85", "#1b6ca8", "#cd201f"),
size_point = 3.5,
size_line = 0.8,
linewidth = 0.8,
size_title = 12,
size_axis_title = base_size,
base_size = 10,
Expand Down Expand Up @@ -53,7 +53,7 @@ plot.see_check_collinearity <- function(x,
.plot_diag_vif(
dat,
size_point = size_point,
size_line = size_line,
linewidth = linewidth,
size_title = size_title,
size_axis_title = size_axis_title,
base_size = base_size,
Expand All @@ -66,7 +66,7 @@ plot.see_check_collinearity <- function(x,

.plot_diag_vif <- function(x,
size_point,
size_line,
linewidth,
theme_style = theme_lucid,
size_title = 12,
size_axis_title = 10,
Expand Down Expand Up @@ -132,7 +132,7 @@ plot.see_check_collinearity <- function(x,
if (!is.null(ci_data)) {
p <- p +
ggplot2::geom_linerange(
linewidth = size_line,
linewidth = linewidth,
na.rm = TRUE
) +
ggplot2::geom_segment(
Expand Down
4 changes: 2 additions & 2 deletions R/plot.check_heteroscedasticity.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
plot.see_check_heteroscedasticity <- function(x,
data = NULL,
size_point = 2,
size_line = 0.8,
linewidth = 0.8,
size_title = 12,
size_axis_title = base_size,
base_size = 10,
Expand Down Expand Up @@ -79,7 +79,7 @@ plot.see_check_heteroscedasticity <- function(x,
.plot_diag_homogeneity(
dat,
size_point = size_point,
size_line = size_line,
linewidth = linewidth,
base_size = base_size,
size_title = size_title,
size_axis_title = size_axis_title,
Expand Down
8 changes: 4 additions & 4 deletions R/plot.check_homogeneity.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ plot.see_check_homogeneity <- function(x, data = NULL, ...) {

.plot_diag_homogeneity <- function(x,
size_point,
size_line,
linewidth,
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,
alpha_dot = 0.8,
show_dots = TRUE) {
p <- ggplot2::ggplot(x, ggplot2::aes(x = .data$x, .data$y))

Expand All @@ -149,7 +149,7 @@ plot.see_check_homogeneity <- function(x, data = NULL, ...) {
geom_point2(
colour = colors[2],
size = size_point,
alpha = dot_alpha_level
alpha = alpha_dot
)
}

Expand All @@ -159,7 +159,7 @@ plot.see_check_homogeneity <- function(x, data = NULL, ...) {
se = TRUE,
alpha = alpha_level,
formula = y ~ x,
linewidth = size_line,
linewidth = linewidth,
colour = colors[1]
) +
ggplot2::labs(
Expand Down
48 changes: 24 additions & 24 deletions R/plot.check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ plot.see_check_model <- function(x,
panel <- attr(x, "panel")
check <- attr(x, "check")
size_point <- attr(x, "dot_size")
size_line <- attr(x, "line_size")
linewidth <- attr(x, "line_size")
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")
alpha_dot <- attr(x, "alpha_dot")
show_dots <- attr(x, "show_dots")
detrend <- attr(x, "detrend")
model_info <- attr(x, "model_info")
Expand Down Expand Up @@ -73,8 +73,8 @@ plot.see_check_model <- function(x,
alpha_level <- 0.2
}

if (is.null(dot_alpha_level)) {
dot_alpha_level <- 0.8
if (is.null(alpha_dot)) {
alpha_dot <- 0.8
}

if (is.null(base_size)) {
Expand All @@ -101,7 +101,7 @@ plot.see_check_model <- function(x,
p$PP_CHECK <- plot.see_performance_pp_check(
x$PP_CHECK,
style = style,
size_line = size_line,
linewidth = linewidth,
size_point = size_point,
base_size = base_size,
size_axis_title = size_axis_title,
Expand All @@ -117,14 +117,14 @@ plot.see_check_model <- function(x,
p$NCV <- .plot_diag_linearity(
x$NCV,
size_point = size_point,
size_line = size_line,
linewidth = linewidth,
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,
alpha_dot = alpha_dot,
show_dots = show_dots
)
}
Expand Down Expand Up @@ -152,7 +152,7 @@ plot.see_check_model <- function(x,
size_axis_title = size_axis_title,
size_title = size_title,
colors = colors[c(1, 2)],
size_line = size_line,
linewidth = linewidth,
type = overdisp_type
)
}
Expand All @@ -161,14 +161,14 @@ plot.see_check_model <- function(x,
p$HOMOGENEITY <- .plot_diag_homogeneity(
x$HOMOGENEITY,
size_point = size_point,
size_line = size_line,
linewidth = linewidth,
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,
alpha_dot = alpha_dot,
show_dots = show_dots
)
}
Expand All @@ -178,14 +178,14 @@ plot.see_check_model <- function(x,
x$INFLUENTIAL,
show_labels = show_labels,
size_text = size_text,
size_line = size_line,
linewidth = linewidth,
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,
alpha_dot = alpha_dot,
show_dots = show_dots
)
}
Expand All @@ -194,7 +194,7 @@ plot.see_check_model <- function(x,
p$VIF <- .plot_diag_vif(
x$VIF,
size_point = 1.5 * size_point,
size_line = size_line,
linewidth = linewidth,
theme_style = style,
base_size = base_size,
size_axis_title = size_axis_title,
Expand All @@ -209,10 +209,10 @@ plot.see_check_model <- function(x,
if (inherits(x$QQ, "performance_simres")) {
p$QQ <- plot(
x$QQ,
size_line = size_line,
linewidth = linewidth,
size_point = 0.9 * size_point,
alpha = alpha_level,
dot_alpha = dot_alpha_level,
alpha_dot = alpha_dot,
colors = colors,
detrend = detrend,
style = style,
Expand All @@ -224,15 +224,15 @@ plot.see_check_model <- function(x,
p$QQ <- .plot_diag_qq(
x$QQ,
size_point = size_point,
size_line = size_line,
linewidth = linewidth,
size_axis_title = size_axis_title,
size_title = size_title,
alpha_level = alpha_level,
detrend = detrend,
theme_style = style,
base_size = base_size,
colors = colors,
dot_alpha_level = dot_alpha_level,
alpha_dot = alpha_dot,
show_dots = TRUE, # qq-plots w/o dots makes no sense
model_info = model_info,
model_class = model_class
Expand All @@ -243,7 +243,7 @@ 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,
linewidth = linewidth,
alpha_level = alpha_level,
theme_style = style,
base_size = base_size,
Expand All @@ -257,14 +257,14 @@ plot.see_check_model <- function(x,
ps <- .plot_diag_reqq(
x$REQQ,
size_point,
size_line,
linewidth,
size_axis_title = size_axis_title,
size_title = size_title,
alpha_level = alpha_level,
theme_style = style,
base_size = base_size,
colors = colors,
dot_alpha_level = dot_alpha_level,
alpha_dot = alpha_dot,
show_dots = TRUE # qq-plots w/o dots makes no sense
)

Expand All @@ -285,14 +285,14 @@ plot.see_check_model <- function(x,

.plot_diag_linearity <- function(x,
size_point,
size_line,
linewidth,
size_axis_title = 10,
size_title = 12,
alpha_level = 0.2,
theme_style = theme_lucid,
base_size = 10,
colors = unname(social_colors(c("green", "blue", "red"))),
dot_alpha_level = 0.8,
alpha_dot = 0.8,
show_dots = TRUE) {
p <- ggplot2::ggplot(x, ggplot2::aes(x = .data$x, y = .data$y))

Expand All @@ -301,7 +301,7 @@ plot.see_check_model <- function(x,
geom_point2(
colour = colors[2],
size = size_point,
alpha = dot_alpha_level
alpha = alpha_dot
)
}

Expand All @@ -311,7 +311,7 @@ plot.see_check_model <- function(x,
se = TRUE,
formula = y ~ x,
alpha = alpha_level,
linewidth = size_line,
linewidth = linewidth,
colour = colors[1]
) +
ggplot2::geom_hline(yintercept = 0, linetype = "dashed") +
Expand Down
Loading

0 comments on commit f8baf90

Please sign in to comment.