Work

RGraphSpace: Rendering graphs as coherent spatial objects in ggplot2

Year: 2026
Type: article
Abstract: A graph describes a network structure of nodes connected by edges, and is used across many areas of science to represent relationships between entities. When the relationships themselves are spatial, node positions carry physical meaning, and the graph must be further represented within an external frame of reference. In R, igraph (Csardi & Nepusz, 2006) provides powerful tools for network analysis, and the ggplot2 ecosystem (Wickham, 2016) does the same for visualization, drawing nodes and edges as separate layers. Integrating the two remains challenging, however, because the geometry of these layers is not fully coordinated at rendering time, a consequence of ggplot2's input model in which each plot layer consumes a single rectangular table and is resolved independently. This design works remarkably well for most applications but is restrictive for graph structures with mutually dependent components. Because layers do not share transformed states, the graph is not rendered as a single coherent object. Here we introduce RGraphSpace, a streamlined interface that integrates igraph with ggplot2 graphics within a normalized coordinate space. It synchronizes node and edge layers, jointly resolving their geometry under standard aesthetic mappings. This coherence lets the graph be anchored to external reference frames, where it becomes a spatial object embedded in a wider context. Statement of needGraph handling in R rests on two mature foundations: igraph (Csardi & Nepusz, 2006) for network analysis and ggplot2 (Wickham, 2016) for layered visualization. The ggraph package (Pedersen, 2025a) bridges these, exposing relational data to the grammar of graphics. Graph data manipulation has similarly matured through tidygraph (Pedersen, 2025b), which represents graphs as tidy node and edge tables. Yet rendering a graph as a spatial object requires coordination across its components. Because ggplot2 resolves each layer independently, node and edge layers are not fully synchronized. Positional coordinates are shared, but other aesthetics are resolved per layer, so edges have no access to the rendered sizes of the nodes.RGraphSpace addresses this by mapping an igraph object into a normalized coordinate space in which nodes, edges, and their associated elements are resolved together. With node and edge geometries synchronized at rendering time, edges are drawn with respect to the final extent of the nodes they connect, and this correspondence is maintained even when node attributes are rescaled through the ggplot2 grammar. This normalized space serves a second purpose, placing the graph within a broader spatial Carazza-Kessler et al. (2026).RGraphSpace: Rendering graphs as coherent spatial objects in ggplot2.
Language: English
Open Access status: diamond
OpenAlex ID: W7220976325
FWCI:
Cites: 17
Cited by:
Related to: 10