alishinski / lavaanPlot

R package for plotting lavaan path models with DiagrammeR
http://alexlishinski.com/lavaanPlot/
39 stars 4 forks source link

Plot latent variables on the left-hand side, observed variable on the right. #36

Closed igavronski closed 2 years ago

igavronski commented 2 years ago

Hi there, I would like to plot a CFA with the latent variables on the left, instead of on the top. For example:

HS.model <- ' visual  =~ x1 + x2 + x3      
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9 
'

fit <- cfa(HS.model, data=HolzingerSwineford1939)

lavaanPlot(model = fit, edge_options = list(color = "grey"))

Plots: Rplot

And I would like to have:

Rplot2

What needs to change in the lavaanPlot call to achieve the above plot?

Thanks in advance,

Iuri.

igavronski commented 2 years ago

Found myself:

lavaanPlot(model = fit, graph_options=list(rankdir="LR"), edge_options = list(color = "grey"))

Got from the documentation in: https://www.graphviz.org/doc/info/shapes.html

@alishinski , could you please update/upgrade the documentation with such an example?

alishinski commented 2 years ago

This is a good idea, thanks for the suggestion!

alishinski commented 2 years ago

Updated the intro to lavaanPlot vignette with some orientation and layout examples in: https://github.com/alishinski/lavaanPlot/commit/018d2a06235a573c93ca2e3b07a8ef35d50583ad

igavronski commented 2 years ago

Your examples are great! Thanks!