gplot {sna} | R Documentation |
gplot
produces a simple two-dimensional plot of graph g
in stack dat
. A variety of options are available to control vertex placement, display details, color, etc.
gplot(dat, g = 1, gmode = "digraph", diag = FALSE, label = c(1:dim(dat)[2]), coord = NULL, jitter = TRUE, thresh = 0, usearrows = TRUE, mode = "segeo", displayisolates = TRUE, interactive = FALSE, boxed.labels = TRUE, xlab = NULL, ylab = NULL, pad = 0.2, vertex.pch = 19, label.cex = 1, vertex.cex = 1, label.col = 1, edge.col = 1, vertex.col = 1, arrowhead.length = 0.2, edge.lty = 1, edge.lwd = 0, edge.len = 0.5, edge.curve = 0.1, edge.steps = 50, diag.size = 0.025, uselen = FALSE, usecurve = FALSE, suppress.axes = TRUE, new = TRUE, layout.par = NULL, ...)
dat |
a graph or graph stack. This data may be valued. |
g |
integer indicating the index of the graph which is to be plotted. By default, g==1 . |
gmode |
String indicating the type of graph being evaluated. "digraph" indicates that edges should be interpreted as directed; "graph" indicates that edges are undirected; "twomode" indicates that data should be interpreted as bimodal (i.e., rows and columns are distinct vertex sets). gmode is set to "digraph" by default. |
diag |
boolean indicating whether or not the diagonal should be treated as valid data. Set this true if and only if the data can contain loops. diag is FALSE by default. |
label |
a vector of vertex labels, if desired; defaults to the vertex index number. |
coord |
user-specified vertex coordinates, in an NCOL(dat)x2 matrix. Where this is specified, it will override the mode setting. |
jitter |
boolean; should the output be jittered? |
thresh |
real number indicating the lower threshold for tie values. Only ties of value >thresh are displayed. By default, thresh =0. |
usearrows |
boolean; should arrows (rather than line segments) be used to indicate edges? |
mode |
the vertex placement algorithm; this must correspond to a gplot.layout function. |
displayisolates |
boolean; should isolates be displayed? |
interactive |
boolean; should interactive adjustment of vertex placement be attempted? |
boxed.labels |
boolean; place vertex labels within boxes? |
xlab |
X axis label. |
ylab |
Y axis label. |
pad |
amount to pad the plotting range; useful if labels are being clipped. |
vertex.pch |
character type for vertices; may be given as a vector, if vertices are to be of different types. |
label.cex |
character expansion factor for label text. |
vertex.cex |
character expansion factor for vertices; may be given as a vector, if vertices are to be of different types. |
label.col |
color for vertex labels; may be given as a vector, if labels are to be of different colors. |
edge.col |
color for edges; may be given as a vector or adjacency matrix, if edges are to be of different colors. |
vertex.col |
color for vertices; may be given as a vector, if vertices are to be of different colors. |
arrowhead.length |
arrowhead length to use with arrow , if usearrows==TRUE . |
edge.lty |
line type for edges; may be given as a vector or adjacency matrix, if edges are to have different line types. |
edge.lwd |
line width scale for edges; if set greater than 0, edge widths are given by edge.lwd*dat . May be given as a vector or adjacency matrix, if edges are to have different line widths. |
edge.len |
if uselen==TRUE , curved edge lengths are scaled by edge.len . |
edge.curve |
if usecurve==TRUE , the extent of edge curvature is controlled by edge.curv . May be given as a fixed value, vector, or adjacency matrix, if edges are to have different levels of curvature. |
edge.steps |
for curved edges (including loops), the number of line segments to use for the curve approximation. |
diag.size |
loop size, if diag==TRUE . |
uselen |
boolean; should we use edge.len to rescale edge lengths? |
usecurve |
boolean; should we use edge.curve ? |
suppress.axes |
boolean; suppress plotting of axes? |
new |
boolean; create a new plot? If new==FALSE , vertices and edges will be added to the existing plot. |
layout.par |
parameters to the gplot.layout function specified in mode . |
... |
additional arguments to plot . |
gplot
is the standard network visualization tool within the sna
library. By means of clever selection of display parameters, a fair amount of display flexibility can be obtained. Graph layout – if not specified directly using coord
– is determined via one of the various available algorithms. These should be specified via the mode
argument; see gplot.layout
for a full list. User-supplied layout functions are also possible – see the aforementioned man page for details.
Note that where gmode=="twomode"
, the supplied two-mode matrix is converted to bipartite adjacency form prior to computing coordinates. If interactive==TRUE
, then the user may modify the initial graph layout by selecting an individual vertex and then clicking on the location to which this vertex is to be moved; this process may be repeated until the layout is satisfactory.
A two-column matrix containing the vertex positions as x,y coordinates.
Carter T. Butts buttsc@uci.edu
Alex Montgomery ahm@stanford.edu
Wasserman, S. and Faust, K. (1994) Social Network Analysis: Methods and Applications. Cambridge: Cambridge University Press.
gplot(rgraph(5)) #Plot a random graph gplot(rgraph(5),usecurv=TRUE) #This time, use curved edges gplot(rgraph(5),mode="mds") #Try an alternative layout scheme