summaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorChris Sobczak <chris@sobczak.family>2026-06-15 17:30:49 -0700
committerChris Sobczak <chris@sobczak.family>2026-06-15 17:30:49 -0700
commit346a38834caca7416b382ed7ce70bc2bb0b8ff6c (patch)
treeba2a0df24f31694dbcc20e6cc2176f302e88922a /R
parenteabeda5c170d81622fa1b8e17e3f3b1783ae7224 (diff)
Fix labels
Diffstat (limited to 'R')
-rw-r--r--R/networkplot.R19
1 files changed, 15 insertions, 4 deletions
diff --git a/R/networkplot.R b/R/networkplot.R
index cbea488..cfc2b13 100644
--- a/R/networkplot.R
+++ b/R/networkplot.R
@@ -159,7 +159,9 @@ networkplot <- function(R, groups = NULL, group_label = NULL, title = NULL, r_la
ggraph::geom_node_point(
ggplot2::aes(
filter = .data$leaf,
- colour = .data$group
+ colour = .data$group,
+ x = .data$x * 1.05,
+ y = .data$y * 1.05
),
size = 2
) +
@@ -167,12 +169,21 @@ networkplot <- function(R, groups = NULL, group_label = NULL, title = NULL, r_la
ggraph::geom_node_text(
ggplot2::aes(
filter = .data$leaf,
- label = .data$name
+ label = .data$name,
+ x = .data$x * 1.1,
+ y = .data$y * 1.1,
+ angle = atan2(.data$y, .data$x) * 180 / pi,
+ hjust = ifelse(
+ atan2(.data$y, .data$x) > pi / 2 | atan2(.data$y, .data$x) < -pi / 2,
+ 1, 0
+ )
),
- # prevents text labels from overlapping
- hjust = 'outward',
size = 2
) +
+ ggplot2::expand_limits(
+ x = c(-1.2, 1.2),
+ y = c(-1.2, 1.2)
+ ) +
ggplot2::theme_void()
if(!is.null(title)){