File: layout_manual.R

package info (click to toggle)
r-cran-ggraph 2.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,832 kB
  • sloc: cpp: 1,630; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 953 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#' Manually specify a layout for layout_tbl_graph
#'
#' This layout function lets you pass the node positions in manually. The
#' supplied positions must match the order of the nodes in the tbl_graph
#'
#' @param graph An `tbl_graph` object
#'
#' @param x,y Expressions with the x and y positions of the nodes
#'
#' @param circular Ignored
#'
#' @return A data.frame with the columns `x`, `y`, `circular` as
#' well as any information stored as node variables in the tbl_graph.
#'
#' @family layout_tbl_graph_*
#'
#' @importFrom rlang enquo eval_tidy quo_is_symbol
#'
layout_tbl_graph_manual <- function(graph, x, y, circular) {
  if (isTRUE(circular)) {
    cli::cli_warn('{.arg circular} argument ignored for manual layout')
  }
  x <- enquo(x)
  y <- enquo(y)
  nodes <- data_frame0(
    x = eval_tidy(x, .N()),
    y = eval_tidy(y, .N()),
    circular = FALSE
  )
  nodes <- combine_layout_nodes(nodes, as_tibble(graph, active = 'nodes'))
  nodes
}