I am learning to plot network graph using ggplot2, igraph and ggnetwork. I am studying this webpage:
https://cran.r-project.org/web/packages/ggnetwork/vignettes/ggnetwork.html#geom_edges
However, I have some very basic questions in order to understand how the functions work. In the example under the heading 'geom_edges', the code is
ggplot(n, aes(x = x, y = y, xend = xend, yend = yend))
+ geom_edges(aes(linetype = type), color = "grey50")
+ theme_blank()
I do not understand
- how does it actually use the ggnetwork package in the statement. Is it implicitly? How?
- what does
x = x, y = y, xend = xend, yend = yend
mean? What are x, y, xend and yend? - how do the parameters x, y, xend, yend relate to the data object n?
Many thanks!
As previous commenters have said, the
x
,xend
,y
andyend
parameters in the example code, which are used to plot nodes and edges between them, work exactly like ingeom_segment
. Theggnetwork
builds onggplot2
, so some knowledge of that package is required to work with it.What the package brings on top of
ggplot2
are functions likegeom_edges
: see its documentation for the full list of functions.