Skip to contents

Creates code to make a diagram in tikz or svg or plot the diagram or store the diagram in a png file.

Usage

lav_plot(model = NULL,
        infile = NULL,
        varlv = FALSE,
        placenodes = NULL,
        edgelabelsbelow = NULL,
        group.covar.indicators = FALSE,
        common.opts = list(sloped.labels = TRUE,
                           mlovcolors = c("lightgreen", "lightblue"),
                           italic = TRUE,
                           lightness = 1,
                           auto.subscript = TRUE),
        rplot = list(outfile = "",
                     addgrid = TRUE),
        tikz = list(outfile = "",
                    cex = 1.3,
                    standalone = FALSE),
        svg = list(outfile = "",
                   stroke.width = 2L,
                   font.size = 20L,
                   idx.font.size = 15L,
                   dy = 5L,
                   font.family = "Latin Modern Math, arial, Aerial, sans",
                   standalone = FALSE)
        )

Arguments

model

A character vector specifying the model in lavaan syntax or a list (or data.frame) with at least members lhs, op, rhs, label and fixed or a fitted lavaan object (in which case the ParTable object is extracted and column est is used as value to show). Should be NULL if infile is given.

infile

A character string specifying the file which contains the model syntax.

varlv

A logical indicating that the (residual) variance of a variable should be plotted as a separate latent variable (with a smaller circle then ordinary latent variables). In this case covariances between two such variables will be plotted as covariance between the latent variables for the variance.

placenodes

optional list with members nodename = c(row, column), row and column don't have to be integers.

edgelabelsbelow

optional list with members c(nodename1, nodename2).

group.covar.indicators

logical, should items with indicators which have an explicit covariance link be placed in the same group, i.e. forced to be on the same side of the diagram?

common.opts

options common to the three types of generated plots.

rplot

options for creating Rplot, see lav_plotinfo_rgraph.

tikz

options for creating code for tikz plot, see lav_plotinfo_tikzcode.

svg

options for creating code for svg plot, see lav_plotinfo_svgcode.

Details

If rplot is specified or neither tikz nor svg are specified an R plot is generated, possibly stored in a png file if the outfile member of rplot is set. If tikz is specified the code for a tikz diagram is stored in the specified outfile, and the same for svg.

The lav_plot command tries to create a nice plot from the input model, but one should keep the names of the variables short and sometimes rearrange the nodes in the plot. As an example the (slightly modified) example of the sem function in lavaan results in the following first plot hereunder. If we use the placenodes argument, we get the second plot. sem example beforesem example after

More details on the parameters can be found in the help for the lav_... functions.

Value

NULL, invisible

Examples