plotGraph | R Documentation |
Plots a mixed graph from an adjacency matrix,
a graphNEL
object, an igraph
object, or
a descriptive vector.
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, ...)
a |
An adjacency matrix: a matrix that consists of 4 different integers as an |
dashed |
A logical value. If |
tcltk |
A logical value. If |
layout |
The name of a function used to compute the (initial) layout of the graph. The default is |
directed |
A logical value. If |
noframe |
A logical value. If |
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 |
plotGraph
uses plot
and tkplot
in igraph package.
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.
Kayvan Sadeghi, Giovanni M. Marchetti
grMAT
, tkplot
, drawGraph
,
plot.igraph
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.