Learn R Programming

tsna (version 0.1.3)

plotPaths: Network Plots a Highlighting Temporal Path(s) .

Description

Wrapper for plot.network with appropriate defaults to plot a highlighted path, or over-plot highlighted paths on a on top of a static aggregate network plot.

Usage

plotPaths(nd, paths,  path.col = rainbow(length(paths), alpha = 0.5), 
           displaylabels = TRUE, coord=NULL, ...)
           
## S3 method for class 'tPath':
plot(x, edge.col = "red", 
              edge.label.col = edge.col, 
              edge.lwd = 10, 
              edge.label.cex = 0.7, 
              displaylabels = TRUE, 
              displayisolates = FALSE, 
              jitter = FALSE, 
              vertex.lwd = (x$gsteps == 0) * 4 + 1, 
              vertex.cex = (x$gsteps == 0) * 1.5, 
              vertex.col = NA, ...)

Arguments

nd
a networkDynamic object to be plotted.
paths
a tPath object containing temporal path (presumably extracted from nd) to be plotted over the network, or a list of paths to be plotted together on the same network.
path.col
vector of valid colors (possibly transparent) to be used for each path. Default will created semi-transparent colors from the rainbow palette.
x
object (assumed to be tPath) to be plotted on top of a static aggregate network plot
...
additional arguments to be passed to plot.network and plot.tPath.
coord
optional numeric matrix of coordinates for positioning vertices. See plot.network
edge.col
color for drawing edges (paths). See plot.network
edge.label.col
color for edge labels. Default to same color as edges. See plot.network
edge.lwd
numeric expansion factor for edge line widths. See plot.network
edge.label.cex
numeric expansion factor for edge labels. See plot.network
displaylabels
logical, should vertex labels be included on the plot? See plot.network
displayisolates
logical, should isolated vertices be included in the plot? See plot.network
jitter
adds random noise to positions (disabled by default) See plot.network
vertex.lwd
Vertex border line with. See plot.network
vertex.cex
Vertex expansion factor. Default is to scale up the origin vertex for the path, and not draw the other vertices. See plot.network
vertex.col
Color for vertices. Default is to leave them un-colored. See plot.network

Value

  • Generates a network plot with a highlighted path, invisibly returns the plot coordinates.

Details

plotPaths plots the networkDynamic object using the normal plot.network function and ... arguments. Then calls plot.tPath for each tPath object in paths to over-plot the edges of path onto the network plot using the corresponding path.col color. Use of semi-transparent colors can help (somewhat) improve readability when paths overlap on the same edges.

plot.tPath plots the path information encoded in a single tPath object. It first creates a network using as.network.tPath and then calls plot.network with suitable defaults for drawing (or over-drawing) the path (doesn't display isolated vertices, draws times as edge labels, draws a color around the source vertex, etc. )

See Also

See also tPath

Examples

Run this code
data(moodyContactSim)
v10path<-tPath(moodyContactSim,v=10,start=0)
# plot just the path from v10
plot(v10path)

# plot the path from v10 on top of the network
plotPaths(moodyContactSim,v10path)

# plot the paths from both v10 and v1
v1path<-tPath(moodyContactSim,v=1,start=0)
plotPaths(moodyContactSim,list(v10path,v1path))

# if ndtv package is installed, along with Graphviz system library,
# nice hierarchical trees can be drawn
plot(v10path,
     coord=network.layout.animate.Graphviz(
                   as.network(v10path),
                   layout.par = list(gv.engine='dot')
            ),
            jitter=FALSE
    )

Run the code above in your browser using DataLab