【发布时间】:2020-10-09 11:06:34
【问题描述】:
我正在尝试使用Graphviz 绘制一个lavaan 模型,并且总体上对它的外观感到满意(第一张图),但希望两个维度之间的边缘是弯曲的,而其他所有的边缘都是直的.
是否可以通过指定graph [layout = neato, overlap = FALSE, outputorder = edgesfirst, splines = curved] 使维度之间的边缘(边缘d1 到d2)弯曲,正如您在第二张图中看到的那样,但这会使它们全部弯曲。
谁能指导我如何得到想要的结果?
这是重现第一张图的代码:
grViz("
digraph CFA {
graph [layout = neato, overlap = FALSE, outputorder = edgesfirst]
node [shape = rectangle]
edge [arrowhead = vee]
# Nodes (variables)
m1 [pos = '-5,1.5!', label = 'VAR1']
m2 [pos = '-5,0.5!', label = 'VAR2']
m3 [pos = '-5,-0.5!', label = 'VAR3']
m4 [pos = '-5,-1.5!', label = 'VAR4']
d1 [pos = '-1.5,0!', label = 'Info', shape = ellipse, width=1]
d2 [pos = '1.5,0!', label = 'Support', shape = ellipse, width=1]
m5 [pos = '5,1.5!', label = 'VAR5']
m6 [pos = '5,0.5!', label = 'VAR6']
m7 [pos = '5,-0.5!', label = 'VAR7']
m8 [pos = '5,-1.5!', label = 'VAR8']
# Edges (loadings)
d1->m1 [label = '1']
d1->m2 [label = '0.82']
d1->m3 [label = '1.20']
d1->m4 [label = '0.70']
d2->m5 [label = '1']
d2->m6 [label = '0.89']
d2->m7 [label = '1.08']
d2->m8 [label = '1.15']
# Define Error
m1->m1 [label = '0.34', dir=both, tailport = 'sw', headport = 'nw', arrowhead=curve, arrowtail=curve, style=dashed]
m2->m2 [label = '0.45', dir=both, tailport = 'sw', headport = 'nw', arrowhead=curve, arrowtail=curve, style=dashed]
m3->m3 [label = '0.28', dir=both, tailport = 'sw', headport = 'nw', arrowhead=curve, arrowtail=curve, style=dashed]
m4->m4 [label = '0.98', dir=both, tailport = 'sw', headport = 'nw', arrowhead=curve, arrowtail=curve, style=dashed]
m5->m5 [label = '0.64', dir=both, tailport = 'se', headport = 'ne', arrowhead=curve, arrowtail=curve, style=dashed]
m6->m6 [label = '0.31', dir=both, tailport = 'se', headport = 'ne', arrowhead=curve, arrowtail=curve, style=dashed]
m7->m7 [label = '0.42', dir=both, tailport = 'se', headport = 'ne', arrowhead=curve, arrowtail=curve, style=dashed]
m8->m8 [label = '0.25', dir=both, tailport = 'se', headport = 'ne', arrowhead=curve, arrowtail=curve, style=dashed]
d1->d1 [label = '0.65', dir=both, tailport = 'se', headport = 'ne', arrowhead=curve, arrowtail=curve, style=dashed]
d2->d2 [label = '0.72', dir=both, tailport = 'sw', headport = 'nw', arrowhead=curve, arrowtail=curve, style=dashed]
# Covariance
d1->d2 [label = '0.45', dir = both, arrowhead=vee, arrowtail=vee, splines=curved, tailport = 's', headport = 's']
}
")
下面是情节:
第一个所有边都是直的 CFA 图
第二个带有弯曲边缘的 CFA 图
【问题讨论】: