Learn R Programming

qgraph (version 1.9.8)

makeBW: A qgraph plot can be understood in black and white

Description

Plot a qgraph network that can be understood also in black and white or grayscale. Positive lines are full and negative ones are dashed. Nodes colors are associated to unique motifs. Up to 12 different motifs are supported at the moment.

Usage

makeBW(x, colorlist = NA,  plot = TRUE)

Value

Silently returns a qgraph object "x" in which two new elements are present, "$graphAttributes$Nodes$density" and "$graphAttributes$Nodes$angles", which affect how the nodes are plotted. Can also be further customized and then re-plotted using plot(x).

Arguments

x

A qgraph object

colorlist

Optional: a vector of colors. See details.

plot

logical: if FALSE, the network is not plotted.

Author

Giulio Costantini

Details

If no colorlist is specified, each color is randomly associated to one of the motifs. Specifying colorlist serves for (a) assigning colors to a specific motif, because the first color in the vector will always be associated to the first motif (this can be used e.g., for being consistent across plots), or (b) for associating motifs only to some of the colors, but not to others, since only in colors in the colorlist are associated to motifs if a colorlist is specified.

Examples

Run this code

set.seed(1)
x <- cor(matrix(rnorm(25), nrow = 5))
colors <- c("red", "red", "blue", "blue", "white")

# colored qgraph plot
qg <- qgraph(x, colors = colors)

# randomly assing motifs to colors (notice that white nodes stay white)
makeBW(qg)
# associate a motif only to one of the colors
makeBW(qg, colorlist = c("blue"))
# define an order, which allows to choose motifs
makeBW(qg, colorlist = c("blue", "red"))
makeBW(qg, colorlist = c("red", "blue"))

Run the code above in your browser using DataLab