diff options
| -rw-r--r-- | R/networkplot.R | 19 | ||||
| -rw-r--r-- | man/networkplot.Rd | 12 |
2 files changed, 26 insertions, 5 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)){ diff --git a/man/networkplot.Rd b/man/networkplot.Rd index 4337a31..c0a0a3e 100644 --- a/man/networkplot.Rd +++ b/man/networkplot.Rd @@ -4,14 +4,24 @@ \alias{networkplot} \title{Network Plot} \usage{ -networkplot(R, groups = NULL, title = NULL) +networkplot( + R, + groups = NULL, + group_label = NULL, + title = NULL, + r_label = "Correlation" +) } \arguments{ \item{R}{A square numeric matrix with names columns and rows} \item{groups}{Optional data.frame mapping nodes to groups} +\item{group_label}{Optional string labeling the kind of grouping} + \item{title}{Optional plot title} + +\item{r_label}{The string naming the relationship type (default 'Correlation')} } \value{ A ggraph object |
