annotation_gspace: Annotate a GraphSpace Plot

View source: R/annotation-gspace.R

annotation_gspaceR Documentation

Annotate a GraphSpace Plot

Description

annotation_gspace() is a generic dispatcher for adding annotation layers to a ggplot-based GraphSpace plot. The type argument selects the annotation type; additional arguments are forwarded to the corresponding handler.

Usage

annotation_gspace(..., type = "image")

annotation_gspace_image(
  raster,
  interpolate = FALSE,
  opacity = 1,
  flip.v = FALSE,
  flip.h = FALSE
)

Arguments

...

Arguments forwarded to the annotation handler selected by type.

type

A string specifying the annotation type. Currently available: "image" (default), dispatched to annotation_gspace_image().

raster

An image to be displayed. Accepted types:

  • A GraphSpace object — the image is extracted via gs_image.

  • A raster object (see as.raster).

  • A matrix or 3D array (RGB/RGBA), coerced to raster automatically.

interpolate

A logical value indicating whether to apply linear interpolation when the image is rendered at a different resolution than its native size. Defaults to FALSE.

opacity

A numeric value in [0, 1] controlling the transparency of the image. 1 is fully opaque (default); 0 is fully transparent.

flip.v

A logical value; if TRUE, the image is flipped vertically (top-to-bottom). Defaults to FALSE.

flip.h

A logical value; if TRUE, the image is flipped horizontally (left-to-right). Defaults to FALSE.

Value

A ggplot2 layer object that can be added to a ggplot() call with +, or invisible(NULL) with a warning if the image could not be resolved.

See Also

annotation_raster, gs_image, geom_nodespace, geom_edgespace

Examples


# Assuming 'gs' is a GraphSpace object with 
# an image stored in gs_image(gs)

## Not run: 
# Pass a GraphSpace object directly
ggplot(gs) +
  annotation_gspace(gs) +
  geom_edgespace() +
  geom_nodespace()

# Extract the image explicitly
ggplot(gs) +
  annotation_gspace(gs_image(gs)) +
  geom_edgespace() +
  geom_nodespace()

# Dim the background and flip vertically
ggplot(gs) +
  annotation_gspace(gs, opacity = 0.5, flip.v = TRUE) +
  geom_edgespace() +
  geom_nodespace()
  

## End(Not run)

RGraphSpace documentation built on June 13, 2026, 9:06 a.m.