gplot
produces a two-dimensional plot of graph g
in collection dat
. A variety of options are available to control vertex placement, display details, color, etc.
gplot(dat, g = 1, gmode = "digraph", diag = FALSE, label = NULL, coord = NULL, jitter = TRUE, thresh = 0, thresh.absval=TRUE, usearrows = TRUE, mode = "fruchtermanreingold", displayisolates = TRUE, interactive = FALSE, interact.bycomp = FALSE, xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, pad = 0.2, label.pad = 0.5, displaylabels = !is.null(label), boxed.labels = FALSE, label.pos = 0, label.bg = "white", vertex.enclose = FALSE, vertex.sides = NULL, vertex.rot = 0, arrowhead.cex = 1, label.cex = 1, loop.cex = 1, vertex.cex = 1, edge.col = 1, label.col = 1, vertex.col = NULL, label.border = 1, vertex.border = 1, edge.lty = NULL, edge.lty.neg=2, label.lty = NULL, vertex.lty = 1, edge.lwd = 0, label.lwd = par("lwd"), edge.len = 0.5, edge.curve = 0.1, edge.steps = 50, loop.steps = 20, object.scale = 0.01, uselen = FALSE, usecurve = FALSE, suppress.axes = TRUE, vertices.last = TRUE, new = TRUE, layout.par = NULL, ...)
g==1
. "digraph"
indicates that edges should be interpreted as directed; "graph"
indicates that edges are undirected; "twomode"
indicates that data should be interpreted as two-mode (i.e., rows and columns are distinct vertex sets). gmode
is set to "digraph"
by default. diag
is FALSE
by default. mode
setting. thresh
(by default in absolute value - see thresh.absval
)are displayed. By default, thresh
=0.gplot.layout
function. interactive==TRUE
, should all vertices in the component be moved? boxed.labels==TRUE
), in character size units. 0
results in labels which are placed away from the center of the plotting region; 1
, 2
, 3
, and 4
result in labels being placed below, to the left of, above, and to the right of vertices (respectively); and label.pos>=5
results in labels which are plotted with no offset (i.e., at the vertex positions). boxed.labels==TRUE
); may be a vector, if boxes are to be of different colors.boxed.labels==TRUE
); may be given as a vector, if label boxes are to have different colors. edge.lty
.boxed.labels==TRUE
); may be given as a vector, if label boxes are to have different line types. edge.lwd*dat
. May be given as a vector or adjacency matrix, if edges are to have different line widths. boxed.labels==TRUE
); may be given as a vector, if label boxes are to have different line widths. uselen==TRUE
, curved edge lengths are scaled by edge.len
. 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.len
to rescale edge lengths? edge.curve
? new==FALSE
, vertices and edges will be added to the existing plot. gplot.layout
function specified in mode
. 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 network is converted to bipartite form prior to computing coordinates (if not in that form already). vertex.col
or other settings may be used to differentiate row and column vertices -- by default, row vertices are drawn as red circles, and column vertices are rendered as blue squares. 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. If interact.bycomp==TRUE
as well, the vertex and all other vertices in the same component as that vertex are moved together.
plot
, gplot.layout
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
#A colorful demonstration...
gplot(rgraph(5,diag=TRUE),diag=TRUE,vertex.cex=1:5,vertex.sides=3:8,
vertex.col=1:5,vertex.border=2:6,vertex.rot=(0:4)*72,
displaylabels=TRUE,label.bg="gray90")
Run the code above in your browser using DataLab