Skip to contents

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.

Usage

geom_edgespace(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = FALSE,
  size_aes = NULL,
  range = c(1, 6),
  arrow_size = 1,
  arrow_offset = 0.01,
  lineend = "butt",
  linejoin = "mitre"
)

Arguments

mapping

Set of aesthetic mappings created by ggplot2::aes(). These mappings override global aesthetics and are not inherited from the top-level plot.

data

A GraphSpace object.

stat

The statistical transformation to use on the data. Defaults to identity.

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 FALSE.

show.legend

Logical or a named logical vector indicating whether this layer should be included in legends.

inherit.aes

Logical. If FALSE (default), the layer will use aesthetics defined in mapping.

size_aes

Optional node size mapping, created with ggplot2::aes(). Can be used to synchronize geom_nodespace and geom_edgespace to ensure directed edges and arrows are offset from node boundaries. This prevents overlaps when geom_nodespace includes a dynamic size or stroke mappings. For automated scale detection, use inject_nodespace instead.

range

Optional numeric vector of length 2 (default c(1, 6)) specifying the min/max node diameters in mm. Used with size_aes and should match the range in ggplot2::scale_size_continuous() for accurate edge clipping. For automated scale detection, use inject_nodespace instead.

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.

Value

A ggplot2 layer that renders edge segments defined by GeomEdgeSpace.

Details

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.

Aesthetics

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, yendRequired (automatically supplied).
colourNode border colour (see aes_colour_fill_alpha).
alphaTransparency (see aes_colour_fill_alpha).
linetypeEdge line type (see aes_linetype_size_shape).
linewidthEdge 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).

Examples


# Load a demo igraph
data('gtoy1', package = 'RGraphSpace')

# Create a GraphSpace object
gs <- GraphSpace(gtoy1)
#> Validating the 'igraph' object...
#> Creating a 'GraphSpace' object...

if (FALSE) { # \dontrun{

ggplot() +
  geom_edgespace(data = gs) +
  geom_nodespace(data = gs) +
  theme(aspect.ratio = 1)

} # }