R: Plot of a mixed graph

plotGraph {ggm} | R Documentation

## Plot of a mixed graph

### Description

Plots a mixed graph from an adjacency matrix, a `graphNEL` object, an `igraph` object, or a descriptive vector.

### Usage

    plotGraph(a, dashed = FALSE, tcltk = TRUE, layout = layout.auto,
    directed = FALSE, noframe = FALSE, nodesize = 15, vld = 0, vc = "gray",
    vfc = "black", colbid = "FireBrick3", coloth = "black", cex = 1.5, ...)

### Arguments

`a` | An adjacency matrix: a matrix that consists of 4 different integers as an ij-element: 0 for a missing edge between i and j, 1 for an arrow from i to j, 10 for a full line between i and j, and 100 for a bi-directed arrow between i and j. These numbers can be added to generate multiple edges of different types. The matrix must be symmetric w.r.t full lines and bi-directed arrows. Or a graph that can be a `graphNEL` or an `igraph` object.Or a vector of length 3e, where e is the number of edges of the graph, that is a sequence of triples (type,node1label,node2label). The type of edge can be `"a"` (arrows from node1 to node2), `"b"` (arcs), and `"l"` (lines).
`dashed` | A logical value. If `TRUE` the bi-directed edges are plotted as undirected dashed edges.
`tcltk` | A logical value. If `TRUE` the function opens a tcltk device to plot the graphs, allowing the interactive manimulation of the graph. If `FALSE`the function opens a standard device without interaction.
`layout` | The name of a function used to compute the (initial) layout of the graph. The default is `layout.auto`. This can be further adjusted if `tcltk` is `TRUE`.
`directed` | A logical value. If `FALSE` a symmetric adjacency matrix with entries 1 is interpreted as an undirected graph. If `FALSE` it is interpreted as a directed graph with double arrows. If `a` is not an adjacency matrix, it is ignored.
`noframe` | A logical value. If `TRUE`, then the nodes are not circled.
`nodesize` | An integer denoting the size of the nodes (default 15). It can be increased to accommodate larger labels.
`vld` | An integer defining the distance between a vertex and its label. Defaults to 0.
`vc` | Vertex color. Default is "gray".
`vfc` | Vertex frame color. Default is "black".
`colbid` | Color of the bi-directed edges. Default is "FireBrick3".
`coloth` | Color of all the other edges. Default is "black".
`cex` | An integer (defaults to 1) to adjust the scaling of the font of the labels.
`...` | Further arguments to be passed to `plot` or `tkplot`.

### Details

`plotGraph` uses `plot` and `tkplot` in igraph package.

### Value

Plot of the associated graph and returns invisibly a list with two slots: `tkp.id`, `graph`, the input graph as an `igraph` object. The id can be used to get the layout of the adjusted graph. The bi-directed edges are plotted in red.

### Author(s)

Kayvan Sadeghi, Giovanni M. Marchetti

### See Also

`grMAT`, `tkplot`, `drawGraph`, `plot.igraph`

### Examples

    exvec<-c("b",1,2,"b",1,14,"a",9,8,"l",9,11,
             "a",10,8,"a",11,2,"a",11,9,"a",11,10,
             "a",12,1,"b",12,14,"a",13,10,"a",13,12)
    plotGraph(exvec)
    ############################################
    amat<-matrix(c(0,11,0,0,10,0,100,0,0,100,0,1,0,0,1,0),4,4)
    plotGraph(amat)
    plotGraph(makeMG(bg = UG(~a*b*c+ c*d), dg = DAG(a ~ x + z, b ~ z )))
    plotGraph(makeMG(bg = UG(~a*b*c+ c*d), dg = DAG(a ~ x + z, b ~ z )), dashed = TRUE)
    # A graph with double and triple edges
    G <-
    structure(c(0, 101, 0, 0, 100, 0, 100, 100, 0, 100, 0, 100, 0,
    111, 100, 0), .Dim = c(4L, 4L), .Dimnames = list(c("X", "Z",
    "Y", "W"), c("X", "Z", "Y", "W")))
    plotGraph(G)
    # A regression chain graph with longer labels
     plotGraph(makeMG(bg = UG(~Love*Constraints+ Constraints*Reversal+ Abuse*Distress),
       dg = DAG(Love ~ Abuse + Distress, Constraints ~ Distress, Reversal ~ Distress,
       Abuse ~ Fstatus, Distress ~ Fstatus),
       ug = UG(~Fstatus*Schooling+ Schooling*Age)),
       dashed = TRUE, noframe = TRUE)
    # A graph with 4 edges between two nodes.
    G4 = matrix(0, 2, 2); G4[1,2] = 111; G4[2,1] = 111
    plotGraph(G4)

[Package ggm version 2.3 Index]