node_coords: Node Coordinates

View source: R/arcplot.r

node_coordsR Documentation

Node Coordinates

Description

Computes axis locations of each node. This function can be helpful when you want to separately plot the node labels using the function mtext.

Usage

node_coords(edgelist, sorted = FALSE, decreasing = FALSE, ordering = NULL,
  labels = NULL)

Arguments

edgelist

basically a two-column matrix with edges (see graph)

sorted

logical to indicate if nodes should be sorted

decreasing

logical to indicate type of sorting (used only when sorted=TRUE)

ordering

optional numeric vector providing the ordering of nodes (when provided, this parameter overrides sorted=TRUE)

labels

character vector with labels for the nodes

Value

a vector with the location of nodes in the x-axis

Author(s)

Gaston Sanchez

See Also

arcplot

Examples


 ## Not run: 
 # generate a graph
 some_graph = graph.ring(10)
 
 # add names to nodes
 V(some_graph)$name = letters[1:vcount(some_graph)]
 
 # extract edgelist
 edgelist = get.edgelist(some_graph)

 # (default) arc diagram
 arcplot(edgelist, labels=V(some_graph)$name, las=1)
 
 # get x-axis coordinates of nodes
 xcoords = node_coords(edgelist, labels=V(some_graph)$name)
 
 # arc diagram with various labels
 arcplot(edgelist, show.labels=FALSE, show.nodes=TRUE)
 mtext(V(some_graph)$name, side=1, line=0, at=xcoords)
 mtext(rep("node",10), side=1, line=1, at=xcoords, col="gray90")
 
## End(Not run)


gastonstat/arcdiagram documentation built on April 8, 2022, 5:59 a.m.