Ziqi
Ziqi

Reputation: 2554

R: Understanding the ggnetwork package and its usage with ggplot

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

Many thanks!

Upvotes: 0

Views: 660

Answers (1)

Fr.
Fr.

Reputation: 2895

As previous commenters have said, the x, xend, y and yend parameters in the example code, which are used to plot nodes and edges between them, work exactly like in geom_segment. The ggnetwork builds on ggplot2, so some knowledge of that package is required to work with it.

What the package brings on top of ggplot2 are functions like geom_edges: see its documentation for the full list of functions.

Upvotes: 0

Related Questions