nplot: Plot a network

Description Usage Arguments Details Value See Also Examples

View source: R/netplot.r

Description

Plot a network

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
nplot(...)

## S3 method for class 'igraph'
nplot(
  x,
  layout = igraph::layout_nicely(x),
  vertex.size = igraph::degree(x, mode = "in"),
  vertex.label = igraph::vertex_attr(x, "name"),
  edge.width = igraph::edge_attr(x, "weight"),
  ...
)

## S3 method for class 'network'
nplot(
  x,
  layout = sna::gplot.layout.kamadakawai(x, NULL),
  vertex.size = sna::degree(x, cmode = "indegree"),
  vertex.label = network::get.vertex.attribute(x, "vertex.names"),
  ...
)

## Default S3 method:
nplot(
  edgelist,
  layout,
  vertex.size = 1,
  bg.col = "transparent",
  vertex.nsides = 15,
  vertex.color = grDevices::hcl.colors(1),
  vertex.size.range = c(0.01, 0.03),
  vertex.frame.color = grDevices::adjustcolor(vertex.color, red.f = 0.75, green.f =
    0.75, blue.f = 0.75),
  vertex.rot = 0,
  vertex.frame.prop = 0.2,
  vertex.label = NULL,
  vertex.label.fontsize = NULL,
  vertex.label.color = "black",
  vertex.label.fontfamily = "HersheySans",
  vertex.label.fontface = "bold",
  vertex.label.show = 0.3,
  vertex.label.range = c(5, 15),
  edge.width = 1,
  edge.width.range = c(1, 2),
  edge.arrow.size = NULL,
  edge.color = ~ego(alpha = 0.25) + alter,
  edge.curvature = pi/3,
  edge.line.lty = "solid",
  edge.line.breaks = 10,
  sample.edges = 1,
  skip.vertex = FALSE,
  skip.edges = FALSE,
  skip.arrows = skip.edges,
  add = FALSE,
  zero.margins = TRUE,
  ...
)

## S3 method for class 'netplot'
print(x, y = NULL, newpage = TRUE, ...)

Arguments

x

An igraph object.

layout

Numeric two-column matrix with the graph layout.

vertex.size

Numeric vector of length vcount(x). Absolute size of the vertex.

vertex.label

Character vector of length vcount(x). Labels.

edge.width

Vector of length ecount(x).

edgelist

An edgelist.

bg.col

Color of the background.

vertex.nsides

Numeric vector of length vcount(x). Number of sizes of the vertex. E.g. three is a triangle, and 100 approximates a circle.

vertex.color

Vector of length vcount(x). Vertex colors.

vertex.size.range

Vector of length vcount(x).

vertex.frame.color

Vector of length vcount(x).

vertex.rot

Vector of length vcount(x). Passed to npolygon, elevation degree from which the polygon is drawn.

vertex.frame.prop

Vector of length vcount(x). What proportion of the vertex does the frame occupy (values between 0 and 1).

vertex.label.fontsize

Numeric vector.

vertex.label.color

Vector of colors of length vcount(x).

vertex.label.fontfamily

Character vector of length vcount(x).

vertex.label.fontface

See grid::gpar

vertex.label.show

Numeric scalar. Proportion of labels to show as the top ranking according to vertex.size.

vertex.label.range

Numeric vector of size 2 or 3. Relative scale of vertex.label.fontsize in points (see grid::gpar).

edge.width.range

Vector of length ecount(x).

edge.arrow.size

Vector of length ecount(x).

edge.color

A vector of length ecount(x). Can be NULL in which case the color is picked as a mixture between ego and alters' vertex.color values.

edge.curvature

Numeric vector of length ecount(x). Curvature of edges in terms of radians.

edge.line.lty

Vector of length ecount(x).

edge.line.breaks

Vector of length ecount(x). Number of vertices to draw (approximate) the arc (edge).

sample.edges

Numeric scalar between 0 and 1. Proportion of edges to sample.

skip.vertex, skip.edges, skip.arrows

Logical scalar. When TRUE the object is not plotted.

add

Logical scalar.

zero.margins

Logical scalar.

y, ...

Ignored

newpage

Logical scalar. When TRUE calls grid::grid.newpage.

Details

In the case of edge.color, the user can specify colors using netplot-formulae.

Value

An object of class c("netplot", "gTree", "grob", "gDesc"). The object has an additional set of attributes:

In the case of nplot.default, an object of class netplot and grob (see grid::grob) with the following slots:

The children grob contains the following two objects:

See Also

nplot_base

Examples

1
2
3
4
5
6
7
library(igraph)
library(netplot)
set.seed(1)
x <- sample_smallworld(1, 200, 5, 0.03)

plot(x) # ala igraph
nplot(x) # ala netplot

netplot documentation built on June 16, 2021, 9:09 a.m.