| arcplot | R Documentation |
Give me an edgelist and I'll help you plot a pretty damn arc diagram
arcplot(edgelist, vertices, sorted = FALSE, decreasing = FALSE, ordering = NULL, labels = NULL, horizontal = TRUE, above = NULL, col.arcs = "#5998ff77", lwd.arcs = 1.8, lty.arcs = 1, lend = 1, ljoin = 2, lmitre = 1, show.nodes = TRUE, pch.nodes = 19, cex.nodes = 1, col.nodes = "gray80", bg.nodes = "gray80", lwd.nodes = 1, show.labels = TRUE, col.labels = "gray55", cex.labels = 0.9, las = 2, font = 1, line = 0, outer = FALSE, adj = NA, padj = NA, axes = FALSE, xlim = NULL, ylim = NULL, ...)
edgelist |
basically a two-column matrix with edges
(see |
vertices |
optional vector of vertex names corresponding with those in the edgelist |
sorted |
logical to indicate if nodes should be sorted
(default |
decreasing |
logical to indicate type of sorting
(used only when |
ordering |
optional numeric or string vector providing the
ordering of nodes. When provided, this parameter overrides
|
labels |
optional string vector with labels for the nodes |
horizontal |
logical indicating whether to plot in horizontal orientation |
above |
optional vector indicating which arcs should be displayed above (or to the right) and below (or to the left) of the axis |
col.arcs |
color for the arcs (default |
lwd.arcs |
line width for the arcs (default 1) |
lty.arcs |
line type for the arcs (see |
lend |
the line end style for the arcs (see |
ljoin |
the line join style for the arcs (see |
lmitre |
the line mitre limit for the arcs (see |
show.nodes |
logical indicating whether to show node symbols |
pch.nodes |
plotting 'character', i.e. symbol to use when
plotting nodes ( |
cex.nodes |
expansion of the node symbols (default 1) |
col.nodes |
color of the node symbols (default |
bg.nodes |
background (fill) color for the node symbols
given by |
lwd.nodes |
line width for drawing node symbols
(see |
show.labels |
logical indicating whether to show node labels |
col.labels |
color of the node labels (default |
cex.labels |
expansion of node labels (default |
las |
numeric in 0,1,2,3; the style of axis labels
(see |
font |
font used for node labels (see |
line |
on which margin line the node labels are displayed,
starting at 0 counting outwards (see |
outer |
use outer margins, if available, to plot node labels
(see |
adj |
adjustment for each string in reading direction
(see |
padj |
adjustment for each string perpendicular to
the reading direction (see |
axes |
logical indicating whether to plot the axes
(default |
xlim |
numeric vector of length 2, giving the x coordinates |
ylim |
numeric vector of length 2, giving the y coordinates |
... |
further graphical parameters (see |
The arcs are scaled such that they fit in a plot region with its
x-axis ranging from zero to one. Node symbols and labels can be
optionally displayed. Node symbols are displayed through
the function points. In turn, node labels are displayed
through the function mtext.
When ordering is provided in numeric format and node labels are
strings, the labels are alphabetically ordered first, and then nodes are
sorted according to the provided ordering.
If ordering is provided in string format, the node labels must be
strings as well. The nodes will be sorted according to ordering.
Gaston Sanchez
xynodes
## Not run:
# create an edgelist
un_graphe <- rbind(
c("fromage", "pain"),
c("pain", "vin"),
c("vin", "biere"),
c("cidre", "biere"),
c("foie", "fromage"),
c("pain", "foie"))
# deafult arcplot
arcplot(un_graphe)
# vertical display
arcplot(un_graphe, horizontal=FALSE)
# arcplot with arcs above and below axis
arcplot(un_graphe, above = c(1, 3, 5))
# nodes sorted alphabetically (increasing)
arcplot(un_graphe, sorted=TRUE)
# nodes sorted alphabetically (decreasing)
arcplot(un_graphe, sorted=TRUE, decreasing = TRUE)
# provided order for nodes
new_order = c("vin", "biere", "cidre", "fromage", "foie", "pain")
arcplot(un_graphe, ordering = new_order)
# generate graphs
ring_graph = graph.ring(10)
star_graph = graph.star(10, mode="out")
tree_graph = graph.tree(10, 2)
# add names to nodes
V(ring_graph)$name = letters[1:vcount(ring_graph)]
V(star_graph)$name = paste("Node", 1:vcount(star_graph))
V(tree_graph)$name = paste("V", 1:vcount(tree_graph), sep='')
# extract edgelist
ring_edges = get.edgelist(ring_graph)
star_edges = get.edgelist(star_graph)
tree_edges = get.edgelist(tree_graph)
# arc diagram
arcplot(ring_edges, labels=V(ring_graph)$name, las=1)
arcplot(star_edges, labels=V(star_graph)$name, las=2)
arcplot(tree_edges, labels=V(tree_graph)$name, las=2)
# compare to plot.igraph
plot(ring_graph, vertex.label=V(ring_graph)$name)
plot(star_graph, vertex.label=V(star_graph)$name)
plot(tree_graph, vertex.label=V(tree_graph)$name)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.