library(RGraphSpace)
library(igraph)
# Load a demo igraph
data('gtoy1', package = 'RGraphSpace')
gs <- GraphSpace(gtoy1)
# Normalize node coordinates
gs <- normalizeGraphSpace(gs)
# Add a raster image
gs_image(gs) <- as_colorraster(volcano)
if (FALSE) {
# Pass a GraphSpace object directly
ggplot(gs) +
annotation_gspace_image(gs) +
geom_edgespace() +
geom_nodespace()
# Extract the image explicitly
ggplot(gs) +
annotation_gspace_image(gs_image(gs)) +
geom_edgespace() +
geom_nodespace()
# Dim the background and flip vertically
ggplot(gs) +
annotation_gspace_image(gs, opacity = 0.5, flip.v = TRUE) +
geom_edgespace() +
geom_nodespace()
}
Run the code above in your browser using DataLab