diff options
| author | Chris Sobczak <chris@sobczak.family> | 2026-06-15 18:04:10 -0700 |
|---|---|---|
| committer | Chris Sobczak <chris@sobczak.family> | 2026-06-15 18:04:10 -0700 |
| commit | c22a8c7b71a54d3c604fef8ab68a10b50e3178cd (patch) | |
| tree | de11d9b9142528ee5209a865eddf6bb03a45b52b /R/networkplot.R | |
| parent | 841057264d27aedb0ca833fc7f2e6eb3ad4bc7e1 (diff) | |
Fix size
Diffstat (limited to 'R/networkplot.R')
| -rw-r--r-- | R/networkplot.R | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/R/networkplot.R b/R/networkplot.R index 01627ea..9d251ea 100644 --- a/R/networkplot.R +++ b/R/networkplot.R @@ -102,6 +102,9 @@ networkplot <- function(R, groups = NULL, group_label = NULL, title = NULL, r_la # this includes the hierarchy vertices (root, groups) # this is required by igraph as a node ID table vertices <- data.frame(name = unique(c(hierarchy$from, hierarchy$to))) + importance <- rowSums(abs(Rm)) / (nrow(Rm) - 1) + vertices$importance <- importance[match(vertices$name, rownames(Rm))] + vertices$importance[is.na(vertices$importance)] <- 0 # If groups were passed, add a column to vertices called group if(!is.null(groups)){ @@ -160,10 +163,14 @@ networkplot <- function(R, groups = NULL, group_label = NULL, title = NULL, r_la ggplot2::aes( filter = .data$leaf, colour = .data$group, + size = .data$importance, x = .data$x * 1.05, y = .data$y * 1.05 - ), - size = 2 + ) + ) + + ggplot2::scale_size_continuous( + range = c(1, 6), # tweak this + guide = "none" # usually better visually ) + # labels nodes and groups ggraph::geom_node_text( @@ -173,14 +180,15 @@ networkplot <- function(R, groups = NULL, group_label = NULL, title = NULL, r_la x = .data$x * 1.1, y = .data$y * 1.1, angle = atan2(.data$y, .data$x) * 180 / pi, - hjust = atan2(.data$y, .data$x) > pi / 2 ), + hjust = 0, size = 2 ) + ggplot2::expand_limits( x = c(-1.2, 1.2), y = c(-1.2, 1.2) ) + + ggraph::scale_edge_alpha(guide = 'none') + ggplot2::theme_void() if(!is.null(title)){ |
