View source: R/geom-edgespace.R
| geom_edgespace | R Documentation |
Constructor for GeomEdgeSpace ggproto objects.
A wrapper around geom_segment that enables direct use of edge attributes stored in GraphSpace objects as aesthetics.
This geom is designed to create edge-level aesthetics such as
colour and linewidth, or any custom aesthetics defined
in GeomEdgeSpace.
geom_edgespace(
mapping = NULL,
data = NULL,
stat = StatEdgeSpace,
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = FALSE,
arrow_size = 1,
arrow_offset = 0.01,
lineend = "butt",
linejoin = "mitre",
raster = FALSE,
dpi = NULL,
dev = "cairo",
scale = 1
)
edgespace_handler()
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. It can be a
GraphSpace object, an igraph object, or the
|
stat |
The statistical transformation to use on the data.
Defaults to |
position |
Position adjustment, either as a string or the result of a call to a position adjustment function. |
... |
Additional parameters passed to the underlying drawing function in GeomEdgeSpace. |
na.rm |
Logical. Should missing values be removed?
Defaults to |
show.legend |
Logical or a named logical vector indicating whether this layer should be included in legends. |
inherit.aes |
Logical. If |
arrow_size |
Numeric scaling factor controlling arrowhead geometry (see 'drawing' section). |
arrow_offset |
Numeric value controlling the base offset of arrows at edge endpoints (see 'drawing' section). |
lineend |
Line end style (round, butt, square). Supplied for compatibility with geom_segment. |
linejoin |
Line join style (round, mitre, bevel). Supplied for compatibility with geom_segment. |
raster |
Logical. Should node glyphs be rasterized?
Rasterization support is based on |
dpi |
Numeric. Rasterization resolution. |
dev |
Character. Rasterization backend. One of |
scale |
Numeric. Rasterization scaling factor
(see |
arrow_size is a numeric scaling factor controlling arrowhead geometry.
The value is interpreted in the same numeric space as line width (lwd),
ensuring consistent scaling between edge strokes and arrowheads.
arrow_offset is an additive term that offsets arrow endpoints uniformly in graph space and is bounded by the edge length, in NPC units.
Arrowhead types are specified in the GraphSpace constructor.
A ggplot2 layer that renders edge segments defined by GeomEdgeSpace.
geom_edgespace() understands geom_segment aesthetics.
If these aesthetics are not explicitly provided in aes(), they
are automatically retrieved from the GraphSpace object.
x, y, xend, yend | Required (automatically supplied). |
colour | Edge colour (see aes_colour_fill_alpha). |
alpha | Transparency (see aes_colour_fill_alpha). |
linetype | Edge line type (see aes_linetype_size_shape). |
linewidth | Edge line width (see aes_linetype_size_shape). |
Required aesthetics (x, y, xend, yend, ...)
are supplied from the GraphSpace object and do not need to be
manually mapped.
Additional parameters can be passed to control fixed values for the layer.
For example: colour = "grey", linetype = 2, linewidth = 1.
Arrows can be further adjusted by arrow_size and arrow_offset
arguments (see details).
geom_edgespace is compatible with the ggraph methods.
When used within a ggraph() call, the default edgespace_handler()
automatically:
Identifies the current layout_ggraph.
Extracts the x and y coordinates calculated by ggraph.
Reconstructs a temporary GraphSpace object to inject spatial
metadata and user-chosen ggraph layout.
GraphSpace, geom_nodespace, geom_graphspace, geom_segment
library(RGraphSpace)
library(igraph)
library(ggplot2)
# Load a demo igraph
data('gtoy1', package = 'RGraphSpace')
# Create a GraphSpace object
gs <- GraphSpace(gtoy1)
## Not run:
ggplot() +
geom_edgespace(data = gs) +
geom_nodespace(data = gs) +
theme(aspect.ratio = 1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.