diff --git a/R/check_dag.R b/R/check_dag.R index 45227f9d1..c45f686ba 100644 --- a/R/check_dag.R +++ b/R/check_dag.R @@ -179,19 +179,21 @@ plot.check_dag <- function(x, size_point = 15, colors = NULL, which = "all", ... p1$data$type <- as.character(p1$data$adjusted) p1$data$type[p1$data$name == attributes(x)$outcome] <- "outcome" p1$data$type[p1$data$name %in% attributes(x)$exposure] <- "exposure" + p1$data$type <- factor(p1$data$type, levels = c("outcome", "exposure", "adjusted", "unadjusted")) p2$data$type <- as.character(p2$data$adjusted) p2$data$type[p2$data$name == attributes(x)$outcome] <- "outcome" p2$data$type[p2$data$name %in% attributes(x)$exposure] <- "exposure" + p2$data$type <- factor(p2$data$type, levels = c("outcome", "exposure", "adjusted", "unadjusted")) if (is.null(colors)) { - point_colors <- see::see_colors(c("red", "cyan", "yellow", "blue grey")) + point_colors <- see::see_colors(c("yellow", "cyan", "blue grey", "red")) } else if (length(colors) != 4) { insight::format_error("`colors` must be a character vector with four color-values.") } else { point_colors <- colors } - names(point_colors) <- c("unadjusted", "exposure", "outcome", "adjusted") + names(point_colors) <- c("outcome", "exposure", "adjusted", "unadjusted") plot1 <- ggplot2::ggplot(p1$data, ggplot2::aes(x = .data$x, y = .data$y)) + see::geom_point_borderless(ggplot2::aes(fill = .data$type), size = size_point) +