plot.network.ergm
produces a simple two-dimensional plot of
the network object x
. A variety of options are available
to control vertex placement, display details, color, etc.
The function is based on the
plotting capabilities of the network
package with additional
pre-processing of arguments.
Some of the capabilites require the latentnet
package.
See plot.network
in the network
package for details.
# S3 method for ergm
plot.network(x,
attrname=NULL,
label=network.vertex.names(x),
coord=NULL,
jitter=TRUE,
thresh=0,
usearrows=TRUE,
mode="fruchtermanreingold",
displayisolates=TRUE,
interactive=FALSE,
xlab=NULL,
ylab=NULL,
xlim=NULL,
ylim=NULL,
pad=0.2,
label.pad=0.5,
displaylabels=FALSE,
boxed.labels=TRUE,
label.pos=0,
label.bg="white",
vertex.sides=8,
vertex.rot=0,
arrowhead.cex=1,
label.cex=1,
loop.cex=1,
vertex.cex=1,
edge.col=1,
label.col=1,
vertex.col=2,
label.border=1,
vertex.border=1,
edge.lty=1,
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,
cex.main=par("cex.main"),
cex.sub=par("cex.sub"),
seed=NULL,
latent.control=list(maxit=500,
trace=0,
dyadsample=10000,
penalty.sigma=c(5,0.5),
nsubsample=200),
colornames="rainbow",
verbose=FALSE,
latent=FALSE,
…)
an object of class network
.
an optional edge attribute, to be used to set edge values.
a vector of vertex labels, if desired; defaults to the vertex labels returned by network.vertex.names
.
user-specified vertex coordinates, in an NCOL(dat)x2 matrix. Where this is specified, it will override the mode
setting.
boolean; should the output be jittered?
real number indicating the lower threshold for tie values. Only ties of value >thresh
are displayed. By default, thresh
=0.
boolean; should arrows (rather than line segments) be used to indicate edges?
the vertex placement algorithm; this must correspond to a network.layout
function.
These include
"latent"
, "latentPrior"
,
and
"fruchtermanreingold"
.
boolean; should isolates be displayed?
boolean; should interactive adjustment of vertex placement be attempted?
x axis label.
y axis label.
the x limits (min, max) of the plot.
the y limits of the plot.
amount to pad the plotting range; useful if labels are being clipped.
amount to pad label boxes (if boxed.labels==TRUE
), in character size units.
boolean; should vertex labels be displayed?
boolean; place vertex labels within boxes?
position at which labels should be placed, relative to vertices. 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).
background color for label boxes (if boxed.labels==TRUE
); may be a vector, if boxes are to be of different colors.
number of polygon sides for vertices; may be given as a vector or a vertex attribute name, if vertices are to be of different types.
angle of rotation for vertices (in degrees); may be given as a vector or a vertex attribute name, if vertices are to be rotated differently.
expansion factor for edge arrowheads.
character expansion factor for label text.
expansion factor for loops; may be given as a vector or a vertex attribute name, if loops are to be of different sizes.
expansion factor for vertices; may be given as a vector or a vertex attribute name, if vertices are to be of different sizes.
color for edges; may be given as a vector, adjacency matrix, or edge attribute name, if edges are to be of different colors.
color for vertex labels; may be given as a vector or a vertex attribute name, if labels are to be of different colors.
color for vertices; may be given as a vector or a vertex attribute name, if vertices are to be of different colors.
label border colors (if boxed.labels==TRUE
); may be given as a vector, if label boxes are to have different colors.
border color for vertices; may be given as a vector or a vertex attribute name, if vertex borders are to be of different colors.
line type for edge borders; may be given as a vector, adjacency matrix, or edge attribute name, if edge borders are to have different line types.
line type for label boxes (if boxed.labels==TRUE
); may be given as a vector, if label boxes are to have different line types.
line type for vertex borders; may be given as a vector or a vertex attribute name, if vertex borders are to have different line types.
line width scale for edges; if set greater than 0, edge widths are scaled by edge.lwd*dat
. May be given as a vector, adjacency matrix, or edge attribute name, if edges are to have different line widths.
line width for label boxes (if boxed.labels==TRUE
); may be given as a vector, if label boxes are to have different line widths.
if uselen==TRUE
, curved edge lengths are scaled by edge.len
.
if usecurve==TRUE
, the extent of edge curvature is controlled by edge.curv
. May be given as a fixed value, vector, adjacency matrix, or edge attribute name, if edges are to have different levels of curvature.
for curved edges (excluding loops), the number of line segments to use for the curve approximation.
for loops, the number of line segments to use for the curve approximation.
base length for plotting objects, as a fraction of the linear scale of the plotting region. Defaults to 0.01.
boolean; should we use edge.len
to rescale edge lengths?
boolean; should we use edge.curve
?
boolean; suppress plotting of axes?
boolean; plot vertices after plotting edges?
boolean; create a new plot? If new==FALSE
, vertices and edges will be added to the existing plot.
parameters to the network.layout
function specified in mode
.
Character expansion for the plot title.
Character expansion for the plot sub-title.
Integer for seeding random number generator. See set.seed
.
A vector of color names that can be selected by index for
the plot. By default it is colors()
.
logical; if this is TRUE
, we will print out more information as we run the function.
logical; use a two-dimensional latent space model based on the MLE fit. See documentation for ergmm()
in latentnet
.
additional arguments to plot
.
None.
mva
plot.network
is a version of the standard network visualization tool
within the sna
package. By means of clever selection
of display parameters, a fair amount of display flexibility
can be obtained. Network layout -- if not specified directly
using coord
-- is determined via one of the various
available algorithms. These are (briefly) as follows:
latentPrior
: Use a two-dimensional latent space model based on a
Bayesian minimum Kullback-Leibler fit.
See documentation for latent()
in ergm
.
random
: Vertices are placed (uniformly) randomly within a square region about the origin.
circle
: Vertices are placed evenly about the unit circle.
circrand
: Vertices are placed in a ``Gaussian donut,'' with distance from the origin following a normal distribution and angle relative to the X axis chosen (uniformly) randomly.
eigen
, princoord
: Vertices are placed via (the real components of) the first two eigenvectors of:
eigen
: the matrix of correlations among (concatenated) rows/columns of the adjacency matrix
princoord
: the raw adjacency matrix.
mds
, rmds
, geodist
, adj
, seham
: Vertices are placed by a metric MDS. The distance matrix used is given by:
mds
: absolute row/column differences within the adjacency matrix
rmds
: Euclidean distances between rows of the adjacency matrix
geodist
: geodesic distances between vertices within the network
adj
: \((\max A)-A\), where \(A\) is the raw adjacency matrix
seham
: structural (dis)equivalence distances
(i.e., as per sedist
in the package sna
)
based on the Hamming metric
spring
, springrepulse
: Vertices are placed
using a simple spring embedder. Parameters for the embedding
model are given by embedder.params
, in the following
order: vertex mass; equilibrium extension; spring coefficient;
repulsion equilibrium distance; and base coefficient of
friction. Initial vertex positions are in random order around
a circle, and simulation proceeds -- increasing the coefficient
of friction by the specified base value per unit time -- until
``motion'' within the system ceases. If springrepulse
is specified, then an inverse-cube repulsion force between
vertices is also simulated; this force is calibrated so as to
be exactly equal to the force of a unit spring extension at
a distance specified by the repulsion equilibrium distance.
Wasserman, S., and Faust, K. (1994). ``Social Network Analysis: Methods and Applications.'' Cambridge: Cambridge University Press.
# NOT RUN {
data(florentine)
plot(flomarriage) #Plot the Florentine Marriage data
plot(network(10)) #Plot a random network
# }
# NOT RUN {
plot(flomarriage,interactive="points")
# }
Run the code above in your browser using DataLab