Skip to contents

Draws a network figure using netplot::nplot(). This is the default plot function used by tabulergm when generating term figures.

Usage

tabulergm_default_plotfun(
  netobj,
  layout,
  vcolor,
  vshape,
  vrotation,
  ecolor,
  directed,
  vsize,
  elinetype,
  ...
)

Arguments

netobj

A network::network object.

layout

A two-column numeric matrix of node coordinates (x, y).

vcolor

Character vector of vertex colors.

vshape

Character or numeric vector of vertex shapes, such as "circle"/"square" or polygon side counts.

vrotation

Numeric vector of vertex rotations (in degrees).

ecolor

Character vector of edge colors.

directed

Logical. Whether the network is directed.

vsize

Numeric vector of vertex sizes.

elinetype

Numeric or character vector of edge line types.

...

Additional arguments (currently unused).

Value

Called for its side-effect of drawing a plot on the current graphics device. Returns invisibly.

Details

A plot function must accept the arguments netobj, layout, vcolor, ecolor, directed, and ..., and draw on the current graphics device.

Examples

# See the default implementation
tabulergm_default_plotfun
#> function (netobj, layout, vcolor, vshape, vrotation, ecolor, 
#>     directed, vsize, elinetype, ...) 
#> {
#>     ewidth <- network::get.edge.attribute(netobj, "weight")
#>     if (!length(vshape)) 
#>         vshape <- "circle"
#>     if (!length(vrotation)) 
#>         vrotation <- 0
#>     if (!length(vsize)) 
#>         vsize <- 1
#>     if (!length(elinetype)) 
#>         elinetype <- "solid"
#>     p <- netplot::nplot(netobj, vertex.color = vcolor, edge.color = ecolor, 
#>         edge.width = ewidth, layout = layout, vertex.size.range = c(0.15, 
#>             0.25, 1), edge.line.breaks = 1, vertex.nsides = vshape, 
#>         vertex.rot = vrotation, vertex.label = NA, edge.width.range = c(10, 
#>             10), vertex.size = vsize, edge.line.lty = elinetype)
#>     print(p)
#>     invisible(NULL)
#> }
#> <bytecode: 0x558ca6220408>
#> <environment: namespace:tabulergm>

# Use a custom plot function
my_plotfun <- function(netobj, layout, vcolor, ecolor, directed, vshape, vrotation, vsize, ...) {
  netplot::nplot(netobj, vertex.color = vcolor, edge.color = ecolor,
                 layout = layout)
}
old <- tabulergm_get_plotfun()
tabulergm_set_plotfun(my_plotfun)
# Restore the previous plot function
tabulergm_set_plotfun(old)