GraphSpace-transform: Crop, rotate, flip, and transpose a GraphSpace

cropGraphSpace,GraphSpace-methodR Documentation

Crop, rotate, flip, and transpose a GraphSpace

Description

Accessory functions to spatially transform a normalized GraphSpace object. cropGraphSpace() subsets the plotting area to a rectangular region; rotateGraphSpace() rotates by a quarter turn; flipGraphSpace() mirrors horizontally or vertically; transposeGraphSpace() swaps the x and y axes.

Usage

## S4 method for signature 'GraphSpace'
cropGraphSpace(gs, xmin = 0, xmax = 1, ymin = 0, ymax = 1, verbose = TRUE)

## S4 method for signature 'GraphSpace'
flipGraphSpace(gs, vertical = TRUE, persist = .is_raw(gs), verbose = TRUE)

## S4 method for signature 'GraphSpace'
rotateGraphSpace(gs, clockwise = TRUE, persist = .is_raw(gs), verbose = TRUE)

## S4 method for signature 'GraphSpace'
transposeGraphSpace(gs, persist = .is_raw(gs), verbose = TRUE)

Arguments

gs

A normalized GraphSpace object.

xmin

A single number in [0,1] specifying the lower x-boundary of the plotting area.

xmax

A single number in [0,1] specifying the upper x-boundary of the plotting area.

ymin

A single number in [0,1] specifying the lower y-boundary of the plotting area.

ymax

A single number in [0,1] specifying the upper y-boundary of the plotting area.

verbose

A single logical value specifying to display detailed messages (when verbose=TRUE) or not (when verbose=FALSE).

vertical

Logical; if TRUE (default), the flip is vertical (mirror top-bottom); if TRUE, horizontal (mirror left-right). (flipGraphSpace only).

persist

Logical; whether the transformation persists through re-normalization. Defaults to TRUE before normalization, FALSE after.

clockwise

Logical; if TRUE (default), the 90-degree turn is clockwise; if TRUE, counter-clockwise (rotateGraphSpace only).

Details

cropGraphSpace() subsets a normalized graph space to a specific region defined by the cropping boundaries. It recalculates node positions and background image boundaries to maintain spatial consistency after cropping, and drops nodes (and edges) that fall outside the window.

rotateGraphSpace(), flipGraphSpace(), and transposeGraphSpace() are all exact, a coordinate/pixel permutation, with no resampling, no interpolation, and no risk of misaligning nodes against the background image. rotateGraphSpace() is restricted to a single 90-degree turn: apply it again to its own output for 180 or 270 degrees. Combine all three with each other to reach any of the 8 symmetries of a square.

Value

A GraphSpace object with updated nodes and canvas slots.

See Also

normalizeGraphSpace

Examples

library(RGraphSpace)
library(igraph)

# Create a star graph
gtoy1 <- make_full_graph(30)

# Create a GraphSpace
gs <- GraphSpace(gtoy1)

gs <- normalizeGraphSpace(gs)

gs_crop <- cropGraphSpace(gs, ymax = 0.5)
gs_rot90 <- rotateGraphSpace(gs)
gs_flip <- flipGraphSpace(gs)
gs_t <- transposeGraphSpace(gs)

plotGraphSpace(gs, node.labels = TRUE)

plotGraphSpace(gs_crop, node.labels = TRUE)


RGraphSpace documentation built on Oct. 9, 2026, 9:07 a.m.