SachaEpskamp / semPlot

Path diagrams and visual analysis of various SEM packages' output
GNU General Public License v2.0
61 stars 20 forks source link

Suggestion: option to connect edges to multiple border points #20

Closed awtur closed 5 years ago

awtur commented 5 years ago

It appears to me that there are no options for allowing the edges to connect to more than one point on the border of nodes (cardinal argument allows only one point). Is this correct?

See comments 1 and 2 in the diagram below: 1) I want the arrows pointing to the center of both the left and right borders. If I use cardinal = F, the arrows on the left side no longer point to the leftmost borders of each node. 2) I want the edges to have a single origin on the left most border.

Thanks for your input.

3

SachaEpskamp commented 5 years ago

One method would be to manually adapt the edge connect points:

graph <- semPaths(...)
graph$graphAttributes$Edges$edgeConnectPoints[ <nodes of interest>, <1 for edges departing node, 2 for edges coming into node>] <- ...
plot(graph)
awtur commented 5 years ago

Thanks Sacha, This gives me the flexibility to define the radians for each edge connection, but I'm afraid it breaks the cardinal = T setting for the covariances, which gave me neat-looking lines (see earlier graph and new one below). Thanks in any event.

123

luxli commented 1 year ago

EDIT: I have solved the issue by using cardinal="manifest", thanks.

Hi Sacha, could you explain how I can determine the values to assign to $edgeConnectPoints please? I saw your answer on stackoverflow using 0.5 pi and 1.5 pi, but I don't know how those values are decided.

Here is a screenshot of a corner of my semplot. I would like the arrows departing from the manifest variables on the top to originate closer to the same point on each manifest variable. Right now they are too spread out, and some arrows look like they are departing from the wrong manifest variable. For example, the two darkest red edges that seem to depart from GAC_6 and ment_2 (pointing towards 4 o'clock direction) are actually from GAC_5 and GAC_6.

Screenshot 2023-06-21 at 12 56 48 AM

Any help would be greatly appreciated.

Here's my code: plot_sem <- semPaths(baseplot, what = "std", nCharNodes = 9, exoVar = F, exoCov = F, intercepts = F, thresholds = F, sizeMan=7, sizeMan2=7, sizeLat=12, sizeLat2=12, edge.label.cex = 0.8, layout = "tree2")

Many thanks!