add_density | R Documentation |
Height curves show where on a plot the concentration of points is largest. In the example below we are interested in where in the network women are concentrated. We compare the density curves of the women with that of the men and we see that men are slightly more concentrated in the core of the network.
add_density(layout, ...)
layout |
a matrix with coordinates often produced by layout_with_fr |
... |
data(den)
den.health <- has.tags(den, "Health", res = "den")
graph.health <- elite.network(den.health)
graph.health <- largest.component(graph.health)
women <- V(graph.health)$name %in% den.health$NAME[den.health$GENDER == "Women"]
lay.health <- layout_with_fr(graph.health, grid = "nogrid")
p <- graph.plot(graph.health, lay.health, vertex.fill = women, edge.color = "black", edge.size = 0.3)
p <- p + scale_fill_manual(values = c("white", "black"), name = "Women")
p + add_density(lay.health[women,], color = "darkred")
p + add_density(lay.health[women == FALSE,], color = "darkred")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.