| normalizeGraphSpace,GraphSpace-method | R Documentation |
Accessory functions to normalize node coordinates in GraphSpace, either by centering them within the graph boundaries or by mapping them to pixel coordinates of a background image.
## S4 method for signature 'GraphSpace'
normalizeGraphSpace(
gs,
mar = 0.1,
use_image = FALSE,
flip.x = FALSE,
flip.y = FALSE,
rotate.xy = FALSE,
flip.v = FALSE,
flip.h = FALSE,
verbose = TRUE,
image = deprecated()
)
## S4 method for signature 'GraphSpace'
cropGraphSpace(gs, crop.coord = c(0, 1, 0, 1), verbose = TRUE)
gs |
A |
mar |
A single numeric value in |
use_image |
Logical; if an image is available, whether to use it as
a background reference map. When enabled, |
flip.x |
Logical; whether to flip the node coordinates along the x-axis. |
flip.y |
Logical; whether to flip the node coordinates along the y-axis. Useful for aligning nodes with image backgrounds, which often use an inverted coordinate system. |
rotate.xy |
Logical; whether to rotate x-y coordinates. |
flip.v |
Logical; whether to vertically flip the background image matrix (top-to-bottom) to align with the graph coordinate system. |
flip.h |
Logical; whether to horizontally flip the background image matrix (left-to-right) to align with the graph coordinate system. |
verbose |
A single logical value specifying to display detailed
messages (when |
image |
Deprecated from RGraphSpace 1.3.0; use gs_image instead. |
crop.coord |
An optional numeric vector of length four specifying a
cropping region (xmin, xmax, ymin, ymax), with values in normalized
coordinates |
These functions provide different strategies for coordinate transformation:
normalizeGraphSpace: Re-scales node coordinates to a
[0, 1] unit square based on the graph's bounding box (when
use_image = FALSE) or maps them to pixel coordinates (when
use_image = TRUE and an image is provided; see gs_image).
It handles image-to-graph alignment via flip.\* and
rotate.\* arguments, used to adjust the graph origin with the
image matrix layout. Users should be aware of the potential discrepancy
between image matrix orientation (top-down) and graph coordinates
(bottom-up). The function attempts to automatically adjust the y-axis to
align the graph's bottom-up coordinates with the image's top-down layout,
but further manual adjustments might be required.
cropGraphSpace: Subsets the normalized graph space into a
specific region defined by crop.coord.
It recalculates node positions and background image boundaries to maintain
spatial consistency after cropping. This function requires a previously
normalized GraphSpace object.
A GraphSpace object with updated nodes
and image slots.
This is an accessory function typically called during
the preprocessing of GraphSpace objects before rendering.
gs_image
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,
crop.coord = c(0, 0.75, 0, 0.75))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.