library(RGraphSpace)
library(igraph)
library(ggplot2)
# Generate a toy star graph
gtoy1 <- make_star(15, mode = "out")
V(gtoy1)$my_node_var <- runif(vcount(gtoy1), 1, 20)
# Create a GraphSpace object
gs <- GraphSpace(gtoy1, layout = layout_in_circle(gtoy1))
if (FALSE) {
# Example 1: Using RGraphSpace-native geoms
# Edge clipping metadata are injected automatically
ggplot(gs) +
geom_edgespace(colour = "red") +
geom_nodespace(aes(size = my_node_var),
fill = "steelblue", stroke = 2) +
scale_size(range = c(2, 15))
# Example 2: Mixing native and general geoms
# Note possible clipping mismatch when combining
# geom_edgespace() with generic ggplot2 node geoms.
# Since geom_point() does not expose the final rendered
# node radius to RGraphSpace, edge clipping is estimated
# from layer parameters and may not exactly match the
# displayed node geometry.
ggplot(gs) +
geom_edgespace(colour = "red") +
geom_point(aes(x, y, size = my_node_var),
fill = "steelblue", stroke = 2, shape = 21) +
scale_size(range = c(2, 15))
}
Run the code above in your browser using DataLab