Adds nodes (and optionally edges) of a gGraph to a ggplot as
ggplot2::geom_sf() layers.
Usage
geom_ggraph(
data = NULL,
mapping = ggplot2::aes(),
edges = FALSE,
stat = "sf",
position = "identity",
na.rm = FALSE,
show.legend = NA,
...
)Arguments
- data
a
gGraphobject.- mapping
aesthetics. Variables from the
gGraph'snode attributes may be used (e.g.aes(color = habitat)).- edges
logical; whether to draw edges. Defaults to
FALSE.- stat, position, na.rm, show.legend, ...
forwarded to
ggplot2::geom_sf().
See also
Other ggplot_methods:
autoplot.gData(),
autoplot.gGraph(),
geom_gdata(),
geom_gpath()
Examples
library(ggplot2)
ggplot() +
geom_ggraph(data = worldgraph.10k, aes(color = habitat), edges = TRUE, size = 0.3) +
scale_color_manual(values = c(land = "grey70", sea = "lightblue", coast = "grey70")) +
coord_sf(crs = "+proj=ortho +lat_0=40 +lon_0=-80") +
theme_void()
