Learn R Programming

RGraphSpace (version 1.1.1)

geom_edgespace: Draw edge elements in a 2D graph layout

Description

Constructor for GeomEdgeSpace ggproto objects, a variant of geom_segment supporting edge attributes and bidirectional arrows.

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",
  ...,
  show.legend = NA,
  inherit.aes = FALSE,
  lineend = "butt",
  linejoin = "mitre",
  arrow_type = 0,
  arrow_size = 1,
  offset_start = 0,
  offset_end = 0
)

Value

A ggplot2 layer that renders edge segments defined by GeomEdgeSpace.

Arguments

mapping

Set of aesthetic mappings created by [ggplot2::aes()]. These mappings apply to the layer and may override global aesthetics.

data

Either a GraphSpace object or a data frame containing edge attributes. If `NULL`, the layer will use the default plot data.

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

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`. Set to `TRUE` if this geom should inherit aesthetics from the plot.

lineend

Line end style (round, butt, square).

linejoin

Line join style (round, mitre, bevel).

arrow_type

Arrowhead types (see 'drawing' section).

arrow_size

Numeric scaling factor controlling arrowhead geometry.

offset_start

Offset arrows as a fraction of graph space at start positions.

offset_end

Offset arrows as a fraction of graph space at end positions.

Aesthetics

`geom_edgespace` understands the following aesthetics:

  • `x` Starting horizontal position in `npc` unit (required).

  • `y` Starting vertical position in `npc` unit (required).

  • `xend` Ending horizontal position in `npc` unit (required).

  • `yend` Ending vertical position in `npc` unit (required).

  • `colour` Edge colour.

  • `linewidth` Edge width, using 'lwd' standard graphics unit (see gpar).

  • `linetype` Line type, using 'lty' standard graphics unit (see gpar).

  • `alpha` Transparency applied to the edge colour.

Details

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

Arrowhead types can be specified using either integer or character codes:
- No arrow: 0 or "---"
- Forward arrow: 1 or "-->"
- Backward arrow: 2 or "<--"
- Bidirectional arrow: 3 or "<->"
- Forward arrow with backward bar: 4 or "|->"
- Forward bar: -1 or "--|"
- Backward bar: -2 or "|--"
- Bidirectional bar: -3 or "|-|"
- Backward arrow with forward bar: -4 or "<-|"

See Also

GeomEdgeSpace, GraphSpace

Examples

Run this code

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

# Create a GraphSpace object
gs <- GraphSpace(gtoy1)

if (FALSE) {

ggplot() + geom_edgespace(aes(x = x, y = y, xend = xend, yend = yend),
  data = gs) + theme(aspect.ratio = 1) + 
  scale_x_continuous(limits = c(0, 1)) +
  scale_y_continuous(limits = c(0, 1))

}

Run the code above in your browser using DataLab