This is a description.
nplot(
x,
layout,
vertex.size = 1,
bg.col = "transparent",
vertex.nsides = 10,
vertex.color = grDevices::hcl.colors(1),
vertex.size.range = c(0.01, 0.03, 4),
vertex.frame.color = NULL,
vertex.rot = 0,
vertex.frame.prop = 0.2,
vertex.label = NULL,
vertex.label.fontsize = NULL,
vertex.label.color = adjustcolor("black", alpha.f = 0.8),
vertex.label.fontfamily = "sans",
vertex.label.fontface = "plain",
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.1, col = "gray") + alter,
edge.curvature = pi/3,
edge.line.lty = "solid",
edge.line.breaks = 5,
sample.edges = 1,
skip.vertex = FALSE,
skip.edges = FALSE,
skip.arrows = skip.edges,
add = FALSE,
zero.margins = TRUE,
edgelist
)# S3 method for igraph
nplot(
x,
layout = igraph::layout_nicely(x),
vertex.size = igraph::degree(x, mode = "in"),
bg.col = "transparent",
vertex.nsides = 10,
vertex.color = grDevices::hcl.colors(1),
vertex.size.range = c(0.01, 0.03, 4),
vertex.frame.color = NULL,
vertex.rot = 0,
vertex.frame.prop = 0.2,
vertex.label = igraph::vertex_attr(x, "name"),
vertex.label.fontsize = NULL,
vertex.label.color = adjustcolor("black", alpha.f = 0.8),
vertex.label.fontfamily = "sans",
vertex.label.fontface = "plain",
vertex.label.show = 0.3,
vertex.label.range = c(5, 15),
edge.width = igraph::edge_attr(x, "weight"),
edge.width.range = c(1, 2),
edge.arrow.size = NULL,
edge.color = ~ego(alpha = 0.1, col = "gray") + alter,
edge.curvature = pi/3,
edge.line.lty = "solid",
edge.line.breaks = 5,
sample.edges = 1,
skip.vertex = FALSE,
skip.edges = FALSE,
skip.arrows = !igraph::is_directed(x),
add = FALSE,
zero.margins = TRUE,
edgelist
)
# S3 method for network
nplot(
x,
layout = sna::gplot.layout.kamadakawai(x, NULL),
vertex.size = sna::degree(x, cmode = "indegree"),
bg.col = "transparent",
vertex.nsides = 10,
vertex.color = grDevices::hcl.colors(1),
vertex.size.range = c(0.01, 0.03, 4),
vertex.frame.color = NULL,
vertex.rot = 0,
vertex.frame.prop = 0.2,
vertex.label = network::get.vertex.attribute(x, "vertex.names"),
vertex.label.fontsize = NULL,
vertex.label.color = adjustcolor("black", alpha.f = 0.8),
vertex.label.fontfamily = "sans",
vertex.label.fontface = "plain",
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.1, col = "gray") + alter,
edge.curvature = pi/3,
edge.line.lty = "solid",
edge.line.breaks = 5,
sample.edges = 1,
skip.vertex = FALSE,
skip.edges = FALSE,
skip.arrows = !network::is.directed(x),
add = FALSE,
zero.margins = TRUE,
edgelist
)
# S3 method for matrix
nplot(
x,
layout,
vertex.size = 1,
bg.col = "transparent",
vertex.nsides = 10,
vertex.color = grDevices::hcl.colors(1),
vertex.size.range = c(0.01, 0.03, 4),
vertex.frame.color = NULL,
vertex.rot = 0,
vertex.frame.prop = 0.2,
vertex.label = NULL,
vertex.label.fontsize = NULL,
vertex.label.color = adjustcolor("black", alpha.f = 0.8),
vertex.label.fontfamily = "sans",
vertex.label.fontface = "plain",
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.1, col = "gray") + alter,
edge.curvature = pi/3,
edge.line.lty = "solid",
edge.line.breaks = 5,
sample.edges = 1,
skip.vertex = FALSE,
skip.edges = FALSE,
skip.arrows = skip.edges,
add = FALSE,
zero.margins = TRUE,
edgelist
)
# S3 method for default
nplot(
x,
layout,
vertex.size = 1,
bg.col = "transparent",
vertex.nsides = 10,
vertex.color = grDevices::hcl.colors(1),
vertex.size.range = c(0.01, 0.03, 4),
vertex.frame.color = NULL,
vertex.rot = 0,
vertex.frame.prop = 0.2,
vertex.label = NULL,
vertex.label.fontsize = NULL,
vertex.label.color = adjustcolor("black", alpha.f = 0.8),
vertex.label.fontfamily = "sans",
vertex.label.fontface = "plain",
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.1, col = "gray") + alter,
edge.curvature = pi/3,
edge.line.lty = "solid",
edge.line.breaks = 5,
sample.edges = 1,
skip.vertex = FALSE,
skip.edges = FALSE,
skip.arrows = skip.edges,
add = FALSE,
zero.margins = TRUE,
...,
edgelist
)
# S3 method for netplot
print(x, y = NULL, newpage = TRUE, legend = TRUE, ...)
An object of class c("netplot", "gTree", "grob", "gDesc"). The object
has an additional set of attributes:
.xlim, .ylim vector of size two with the x-asis/y-axis limits.
.layout A numeric matrix of size vcount(x) * 2 with the vertices positions
.edgelist A numeric matrix, The edgelist.
In the case of nplot.default, an object of class netplot and grob (see
grid::grob) with the following slots:
children The main grob of the object.
name Character scalar. The name of the plot
.xlim and .ylim Two vectors indicating the limits of the plot
.layout A two-column matrix with the location of the vertices.
.edgelist A two-column matrix, an edgelist.
.N Integer. The number of vertices.
.M Integer. The number of edges.
The children
grob contains the following two objects:
background a grob rectangule.
graph a gTree that contains each vertex and each edge
of the figure.
A graph. It supports networks stored as igraph, network, and
matrices objects (see details).
Numeric two-column matrix with the graph layout in x/y positions of the vertices.
Numeric vector of length vcount(x). Absolute size of the vertex from 0 to 1.
Color of the background.
Numeric vector of length vcount(x). Number of sizes of
the vertex. E.g. three is a triangle, and 100 approximates a circle.
Vector of length vcount(x). Vertex HEX or built in colors.
Numeric vector of length 3. Relative size for the
minimum and maximum of the plot, and curvature of the scale. The third number
is used as size^rel[3].
Vector of length vcount(x). Border of vertex in
HEX or built in colors.
Vector of length vcount(x) in Radians. Passed to npolygon,
elevation degree from which the polygon is drawn.
Vector of length vcount(x). What proportion of the
vertex does the frame occupy (values between 0 and 1).
Character vector of length vcount(x). Labels.
Numeric vector.
Vector of colors of length vcount(x).
Character vector of length vcount(x).
See grid::gpar
Numeric scalar. Proportion of labels to show as the
top ranking according to vertex.size.
Numeric vector of size 2 or 3. Relative scale of
vertex.label.fontsize in points (see grid::gpar).
Vector of length ecount(x) from 0 to 1. All edges will be
the same size.
Vector of length ecount(x) from 0 to 1. Adjusting
width according to weight.
Vector of length ecount(x) from 0 to 1.
A vector of length ecount(x). In HEX or built in colors.
Can be NULL in which case
the color is picked as a mixture between ego and alters' vertex.color values.
Numeric vector of length ecount(x). Curvature of edges
in terms of radians.
Vector of length ecount(x). Line types in R
(e.g.- 1 = Solid, 2 = Dashed, etc).
Vector of length ecount(x). Number of vertices to
draw (approximate) the arc (edge).
Numeric scalar between 0 and 1. Proportion of edges to sample.
Logical scalar. When TRUE the
object is not plotted.
Logical scalar.
Logical scalar.
An edgelist.
Ignored
Logical scalar. When TRUE calls grid::grid.newpage.
Logical scalar. When TRUE it adds a legend.
When x is of class matrix, it will be passed to igraph::graph_from_adjacency_matrix().
In the case of edge.color, the user can specify colors using netplot-formulae.
nplot_base
library(igraph)
library(netplot)
set.seed(1)
x <- sample_smallworld(1, 200, 5, 0.03)
plot(x) # ala igraph
nplot(x) # ala netplot
Run the code above in your browser using DataLab