-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hack ggdag a bit to get more consistent output
- Loading branch information
1 parent
808615e
commit 1c9df26
Showing
11 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# this is all a hack to make work with quick plotting | ||
# TODO: when `geom_dag_label_repel2` exists, add to namespace as 1 then delete this first bit | ||
# copied from source to avoid recursion issue in overriding in ggdag namsespace | ||
ggdag_geom_dag_label_repel <- function( | ||
mapping = NULL, data = NULL, parse = FALSE, ..., | ||
box.padding = grid::unit(0.35,"lines"), label.padding = grid::unit(0.25, "lines"), | ||
point.padding = grid::unit(1.5, "lines"), label.r = grid::unit(0.15, "lines"), | ||
label.size = 0.25, segment.color = "grey50", segment.size = 0.5, arrow = NULL, | ||
force = 1, max.iter = 2000, nudge_x = 0, nudge_y = 0, na.rm = FALSE, | ||
show.legend = NA, inherit.aes = TRUE) { | ||
ggplot2::layer(data = data, mapping = mapping, stat = ggdag:::StatNodesRepel, | ||
geom = ggrepel::GeomLabelRepel, position = "identity", | ||
show.legend = show.legend, inherit.aes = inherit.aes, | ||
params = list(parse = parse, box.padding = box.padding, | ||
label.padding = label.padding, point.padding = point.padding, | ||
label.r = label.r, label.size = label.size, segment.colour = segment.color %||% | ||
segment.colour, segment.size = segment.size, | ||
arrow = arrow, na.rm = na.rm, force = force, max.iter = max.iter, | ||
nudge_x = nudge_x, nudge_y = nudge_y, segment.alpha = 1, ...)) | ||
} | ||
|
||
geom_dag_label_repel_internal <- function(..., seed = 10) { | ||
ggdag_geom_dag_label_repel( | ||
mapping = aes(x, y, label = label), | ||
# TODO: make sure this looks ok. slightly different from above | ||
box.padding = 2, | ||
max.overlaps = Inf, | ||
inherit.aes = FALSE, | ||
family = getOption("book.base_family"), | ||
seed = seed, | ||
label.size = NA, | ||
label.padding = 0.1 | ||
) | ||
} | ||
|
||
# apply to quick functions as well | ||
assignInNamespace("geom_dag_label_repel", geom_dag_label_repel_internal, ns = "ggdag") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+1.73 KB
(100%)
_freeze/chapters/chapter-05/figure-html/fig-dag-podcast-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-24.8 KB
(62%)
_freeze/chapters/chapter-05/figure-html/unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-45.1 KB
(48%)
_freeze/chapters/chapter-05/figure-html/unnamed-chunk-13-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-59.4 KB
(41%)
_freeze/chapters/chapter-05/figure-html/unnamed-chunk-14-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-16.1 KB
(77%)
_freeze/chapters/chapter-05/figure-html/unnamed-chunk-16-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
```{r} | ||
#| include: false | ||
source(here::here("R/ggdag-mask.R")) | ||
source(here::here("R/setup.R")) | ||
library(tidyverse) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters