layout_igraph_linear
), though it can be used
elsewere. It draws edges as arcs with a hight proportional to the distance
between the nodes. Arcs are calculated as beziers. For linear layout the
placement of control points are related to the curvature
argument and
the distance between the two nodes. For circular layout the control points
are placed on the same angle as the start and end node at a distance related
to the distance between the nodes.
geom_edge_arc(mapping = NULL, data = get_edges(), position = "identity", arrow = NULL, curvature = 1, n = 100, fold = FALSE, lineend = "butt", linejoin = "round", linemitre = 1, label_colour = "black", label_alpha = 1, label_parse = FALSE, check_overlap = FALSE, angle_calc = "rot", force_flip = TRUE, label_dodge = NULL, label_push = NULL, show.legend = NA, ...)
geom_edge_arc2(mapping = NULL, data = get_edges("long"), position = "identity", arrow = NULL, curvature = 1, n = 100, fold = FALSE, lineend = "butt", linejoin = "round", linemitre = 1, label_colour = "black", label_alpha = 1, label_parse = FALSE, check_overlap = FALSE, angle_calc = "rot", force_flip = TRUE, label_dodge = NULL, label_push = NULL, show.legend = NA, ...)
geom_edge_arc0(mapping = NULL, data = get_edges(), position = "identity", arrow = NULL, curvature = 1, lineend = "butt", show.legend = NA, fold = fold, ...)
get_edges()
or a data.frame
giving edges in corrent format (see details for for guidance on the format).
See get_edges
for more details on edge extraction.arrow
circular = FALSE
.FALSE
.NA
it will use
the colour of the edge.NA
it will use
the opacity of the edge.TRUE
, the labels will be parsed into expressions
and displayed as described in plotmath
.TRUE
, text that overlaps previous text in the
same layer will not be plotted.angle_calc
is either 'along' or 'across'
should the label be flipped if it is on it's head. Default to TRUE
.unit
giving a fixed vertical shift
to add to the label in case of angle_calc
is either 'along' or 'across'unit
giving a fixed horizontal shift
to add to the label in case of angle_calc
is either 'along' or 'across'NA
, the default, includes if any aesthetics are mapped.
FALSE
never includes, and TRUE
always includes.layer
. These are
often aesthetics, used to set an aesthetic to a fixed value, like
color = "red"
or size = 3
. They may also be parameters
to the paired geom/stat.n
) along the edge and draws it as a path. Each point along
the line has a numeric value associated with it giving the position along the
path, and it is therefore possible to show the direction of the edge by
mapping to this e.g. colour = ..index..
. The version postfixed with a
"2" uses the "long" edge format (see get_edges
) and makes it
possible to interpolate node parameter between the start and end node along
the edge. It is considerable less performant so should only be used if this
is needed. The version postfixed with a "0" draws the edge in the most
performant way, often directly using an appropriate grob from the grid
package, but does not allow for gradients along the edge.Often it is beneficial to stop the drawing of the edge before it reaches the
node, for instance in cases where an arrow should be drawn and the arrowhead
shouldn't lay ontop or below the node point. geom_edge_* and geom_edge_*2
supports this through the start_cap and end_cap aesthetics that takes a
geometry
specification and dynamically caps the termini of the
edges based on the given specifications. This means that if
end_cap = circle(1, 'cm')
the edges will end at a distance of 1cm even
during resizing of the plot window.
All geom_edge_*
and geom_edge_*2
have the ability to draw a
label along the edge. The reason this is not a separate geom is that in order
for the label to know the location of the edge it needs to know the edge type
etc. Labels are drawn by providing a label aesthetic. The label_pos can be
used to specify where along the edge it should be drawn by supplying a number
between 0 and 1. The label_size aesthetic can be used to control the size of
the label. Often it is needed to have the label written along the direction
of the edge, but since the actual angle is dependent on the plot dimensions
this cannot be calculated beforehand. Using the angle_calc argument allows
you to specify whether to use the supplied angle aesthetic or whether to draw
the label along or across the edge.
geom_edge_density
,
geom_edge_diagonal
,
geom_edge_elbow
,
geom_edge_fan
,
geom_edge_hive
,
geom_edge_link
,
geom_edge_loop
require(igraph)
# Make a graph with different directions of edges
gr <- graph_from_edgelist(
t(apply(as_edgelist(make_graph('Meredith')), 1, sample))
)
E(gr)$class <- sample(letters[1:3], gsize(gr), replace = TRUE)
V(gr)$class <- sample(letters[1:3], gorder(gr), replace = TRUE)
ggraph(gr, 'linear') +
geom_edge_arc(aes(alpha = ..index..))
ggraph(gr, 'linear') +
geom_edge_arc2(aes(colour = node.class), curvature = 0.6)
ggraph(gr, 'linear', circular = TRUE) +
geom_edge_arc0(aes(colour = class))
Run the code above in your browser using DataLab