Open jebyrnes opened 5 years ago
Bump @alishinski any update on this?
Thanks for the prompt. @jebyrnes can you provide a reproducible example?
Has this been resolved? I also have troubles to position nodes and I can't find any information on what commands to use for repositioning. Any suggestions?
Same issue here; I hope it can still be resolved!
Yes, same issue. @alishinski here is a small reproducible example on how I managed what I wanted. For a small toy CFA I needed the two factors (F1 and F2) to be on the same level (equal y in the case of BT rankdir). This would have been easy if we could modify positioning of nodes, but I had to use rank=same
to achieve desired output.
library(lavaan)
library(lavaanPlot)
corel <- matrix(0.41, 4, 4)
corel[1:2, 1:2] <- 0.64
corel[3:4, 3:4] <- 0.64
diag(corel) <- 1
row.names(corel) <- colnames(corel) <- paste0("i", 1:4)
corel
lav_corel <- "
F1 =~ i1 + i2
F2 =~ i3 + i4
"
lav_corel_m <- lavaan::cfa(lav_corel, sample.cov = corel, estimator = "ML", std.lv = TRUE, sample.nobs = 1000)
lav_corel_d <- lavaanPlot::lavaanPlot2(model = lav_corel_m, graph_options = list(rankdir = "BT"), include = "covs", coef_labels = TRUE)
lav_corel_d
lav_corel_d$x$diagram <- paste0( # edit diagram
substr(lav_corel_d$x$diagram, 1, nchar(lav_corel_d$x$diagram)-1),
"{rank=same;1;2;}",
"}"
)
lav_corel_d
So, I guess the question is here, how we can edit node positions or at least edit some global graph settings linked to their position (like rank
).
If I try and set node_options to something like
node_options = list(x = c(1,2,3,4))
to put my variables in a line, I getAny fix for this so we can make customized plots with nodes where we want them?