geom_edgeset: Plotting of a population graph edge set using ggplot neumonic

View source: R/geom_edgeset.R

geom_edgesetR Documentation

Plotting of a population graph edge set using ggplot neumonic

Description

This function allows you to layer the edgeset of a popgraph object

Usage

geom_edgeset(mapping = NULL, graph = NULL, directed = FALSE, ...)

Arguments

mapping

The aesthetic mapping as an aes() object. This aesthetic must at least have values for x and y

graph

The popgraph/igraph object to be plot

directed

A flag indicating that you should only plot the edge with the largest weight if more than one edge connects nodes.

...

Largely ignored.

Value

A formatted geom_segment object for addition to a ggplot()

Author(s)

Rodney J. Dyer <rjdyer@vcu.edu>

Examples

a <- matrix( c(0,1,0,1,1,0,0,1,0,0,0,1,1,1,1,0),nrow=4)
rownames(a) <- colnames(a) <- LETTERS[1:4]
graph <- as.popgraph(a)
igraph::V(graph)$x <- runif(4)
igraph::V(graph)$y <- runif(4)
igraph::E(graph)$weight <- 1 + rpois(4,2)
require(ggplot2)
ggplot() + geom_edgeset( aes(x=x,y=y), graph )
ggplot() + geom_edgeset( aes(x=x,y=y), graph, color="darkblue" )
ggplot() + geom_edgeset( aes(x=x,y=y, size=weight), graph, color="darkblue" )
ggplot() + geom_edgeset( aes(x=x,y=y, color=weight), graph, color="darkblue" )
require(grid)
ggplot() + geom_edgeset( aes(x=x,y=y), graph, directed=TRUE, arrow=arrow(length=unit(0.5,"cm")) )

dyerlab/popgraph documentation built on July 22, 2022, 5:42 p.m.