Skip to content

Commit

Permalink
allow dropping
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmbarrett committed Mar 7, 2024
1 parent 14c48bd commit aa84adb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions R/relations.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ ggdag_children <- function(
node_children(.var) %>%
ggplot2::ggplot(aes_dag(color = children)) +
scale_adjusted() +
breaks(c("parent", "child"))
breaks(c("parent", "child"), drop = FALSE)

p <- p + geom_dag(
size = size,
Expand Down Expand Up @@ -288,7 +288,7 @@ ggdag_parents <- function(
node_parents(.var) %>%
ggplot2::ggplot(aes_dag(color = parent)) +
scale_adjusted() +
breaks(c("parent", "child"))
breaks(c("parent", "child"), drop = FALSE)

p <- p + geom_dag(
size = size,
Expand Down Expand Up @@ -344,7 +344,7 @@ ggdag_ancestors <- function(
node_ancestors(.var) %>%
ggplot2::ggplot(aes_dag(color = ancestor)) +
scale_adjusted() +
breaks(c("ancestor", "descendant"))
breaks(c("ancestor", "descendant"), drop = FALSE)

p <- p + geom_dag(
size = size,
Expand Down Expand Up @@ -401,7 +401,7 @@ ggdag_descendants <- function(
node_descendants(.var) %>%
ggplot2::ggplot(aes_dag(color = descendant)) +
scale_adjusted() +
breaks(c("ancestor", "descendant"))
breaks(c("ancestor", "descendant"), drop = FALSE)

p <- p + geom_dag(
size = size,
Expand Down
6 changes: 3 additions & 3 deletions R/themes.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ scale_adjusted <- function(include_alpha = FALSE) {
)
}

breaks <- function(breaks = ggplot2::waiver(), name = ggplot2::waiver()) {
breaks <- function(breaks = ggplot2::waiver(), name = ggplot2::waiver(), drop = TRUE) {
list(
ggplot2::scale_color_discrete(name = name, breaks = breaks),
ggplot2::scale_fill_discrete(name = name, breaks = breaks)
ggplot2::scale_color_discrete(name = name, breaks = breaks, drop = drop),
ggplot2::scale_fill_discrete(name = name, breaks = breaks, drop = drop)
)
}

Expand Down

0 comments on commit aa84adb

Please sign in to comment.