geom_nodes | R Documentation |
All arguments to this geom are identical to those of
geom_point
.
geom_nodes( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to |
if (require(network) && require(sna)) { data(flo, package = "network") n <- network(flo, directed = FALSE) # just nodes ggplot(n, aes(x, y)) + geom_nodes(size = 3, shape = 21, colour = "steelblue") + theme_blank() # with edges ggplot(n, aes(x, y, xend = xend, yend = yend)) + geom_edges(colour = "steelblue") + geom_nodes(size = 3, shape = 21, colour = "steelblue", fill = "white") + theme_blank() # with nodes sized according to degree centrality ggplot(n, aes(x, y, xend = xend, yend = yend)) + geom_edges(colour = "steelblue") + geom_nodes(size = degree(n), shape = 21, colour = "steelblue", fill = "white") + theme_blank() # with nodes colored according to betweenness centrality n %v% "betweenness" <- betweenness(flo) ggplot(n, aes(x, y, xend = xend, yend = yend)) + geom_edges(colour = "grey50") + geom_nodes(aes(colour = betweenness), size = 3) + scale_colour_gradient(low = "gold", high = "tomato") + theme_blank() + theme(legend.position = "bottom") }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.