The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
Some features:
library(netplot)
library(igraph)
library(sna)
library(ggraph)
# We will use the UKfaculty data from the igraphdata package
data("UKfaculty", package = "igraphdata")
# With a fixed layout
set.seed(225)
l_ukf <- layout_with_fr(UKfaculty)
Since igraph and statnet do the plotting using base system graphics,
we can’t put everything in the same device right away. Fortunately, the
gridGraphics
R package allows us to reproduce base graphics
using the grid
system, which, in combination with the
function gridExtra::grid.arrange
will let us put both base
and grid graphics in the same page. First me write a func
# Function to map base to grid
map_base_to_grid <- function(fun) {
gridGraphics::grid.echo(fun)
grid::grid.grab()
}
# Mapping base to grid
ig <- map_base_to_grid(function() plot(UKfaculty, main = "igraph"))
nw <- map_base_to_grid(function() gplot(as.matrix(as_adj(UKfaculty)), coord = l_ukf, main = "sna"))
Here is an example with ggraph
ggraph::ggraph(UKfaculty, layout = l_ukf) +
ggraph::geom_edge_arc() +
ggraph::geom_node_point() +
ggplot2::ggtitle("ggraph")
gg <- grid::grid.grab()
To arrange multiple plots in the same page we can use the
grid.arrange
function from the gridExtra
package
gridExtra::grid.arrange(
nplot(UKfaculty, layout = l_ukf, vertex.size.range = c(.025, .025)),
nplot(UKfaculty, layout = l_ukf, vertex.size.range = c(.01, .025)),
nplot(UKfaculty, layout = l_ukf, vertex.size.range = c(.01, .025, 4)),
nplot(UKfaculty, layout = l_ukf, vertex.size.range = c(.02, .05, 4)),
ncol=2, nrow=2
)
gridExtra::grid.arrange(
nplot(
x, layout = l,
edge.color = ~ego(mix=0, alpha = .1, col="black") + alter(mix=1),
vertex.size.range = c(.05,.1)
),
nplot(
x, layout = l,
edge.color = ~ego(mix=.5, alpha = .1, col="black") + alter(mix=.5),
vertex.size.range = c(.05,.1)
),
nplot(
x, layout = l,
edge.color = ~ego(mix=1, alpha = .1, col="black") + alter(mix=0),
vertex.size.range = c(.05,.1)
),
ncol=3, nrow=1
)
gridExtra::grid.arrange(
nplot(x, layout = l, edge.curvature = 0, vertex.size.range = c(.05,.1)),
nplot(x, layout = l, edge.curvature = pi/2, vertex.size.range = c(.05,.1)),
nplot(x, layout = l, edge.curvature = pi, vertex.size.range = c(.05,.1)),
ncol = 3, nrow=1
)
gridExtra::grid.arrange(
nplot(x, layout = l, edge.line.breaks=3),
nplot(x, layout = l, edge.line.lty = 2, edge.line.breaks=10),
nplot(x, layout = l, edge.line.lty = 3, edge.line.breaks=10),
nplot(x, layout = l, edge.line.lty = 4, edge.line.breaks=10),
nrow=2, ncol=2
)
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.