Skip to content

Commit

Permalink
legend order
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Aug 3, 2024
1 parent b2e2dc9 commit 1844583
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/check_dag.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down

0 comments on commit 1844583

Please sign in to comment.