geom_edgelabels: Plotting of a population graph edge labels using ggplot...

Description Usage Arguments Value Author(s) Examples

Description

This function allows you to layer the edgeset lables from a popgraph object

Usage

1
2
geom_edgelabels(mapping = NULL, graph = NULL, directed = FALSE,
  offset = c(0, 0), ...)

Arguments

mapping

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

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.

offset

The amount added to each X,Y coordinate to move the label off the line (default=c(0,0)).

...

Options passed to geom_text like color, etc.

Value

A formatted geom_text object for addition to a ggplot()

Author(s)

Rodney J. Dyer <rjdyer@vcu.edu>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)$Label <- LETTERS[1:4]
require(ggplot2)
p <- ggplot() + geom_edgeset( aes(x=x,y=y), graph )
p + geom_edgelabels(aes(x=x,y=y,label=Label),graph)
p + geom_edgelabels(aes(x=x,y=y,label=Label),graph,color="red")
p + geom_edgelabels(aes(x=x,y=y,label=Label),graph,color="red", offset=c(.005,-0.004))

Example output

Loading required package: ggplot2
Loading required package: igraph

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union

popgraph documentation built on April 14, 2017, 9:58 p.m.