Unexpected line artifacts in CFA plot using SemPlot for Lavaan model

I’m having trouble with my SemPlot visualization. The plot looks okay overall, but there are weird lines showing up next to the labels for my observed variables. I can’t figure out why they’re there or how to get rid of them.

Here’s the code I’m using to create the plot:

semPlot::semPaths(
  model_fit,
  residuals = TRUE,
  what = "std",
  label.cex = 1,
  edge.label.cex = 0.5,
  fade = FALSE,
  intercepts = FALSE,
  curveAdjacent = TRUE,
  title = FALSE,
  layout = "tree2",
  sizeMan = 7,
  curvePivot = TRUE,
  borders = FALSE,
  nCharNodes = 0,
  nCharEdges = 0,
  nodeLabels = paste0("V", 1:14)
)

The plot comes out mostly fine, but those extra lines are really bugging me. Has anyone else run into this issue or know how to fix it? I’ve tried adjusting various parameters but nothing seems to help. Any advice would be appreciated!

hey, i’ve seen this before! those lines are super annoying, right? have u tried tweaking the ‘edges’ parameter? sometimes setting edges=“curved” can smooth things out. also, play with ‘layoutSplit’ - it might help with positioning. if nothing works, maybe try ggraph? it’s got more customization options. good luck!

Hey there! Those mysterious lines are definitely a head-scratcher, aren’t they? :thinking: I’ve been playing around with SemPlot too and ran into similar quirks. Have you tried messing with the ‘rotation’ parameter? Sometimes giving it a little twist can shake those pesky artifacts loose.

Also, I’m curious - what version of R and SemPlot are you using? I’ve noticed some of these visual hiccups can be version-specific. Maybe there’s a recent update that addresses this?

Oh, and here’s a wild thought - what if you exported your plot to a different file format? I once had weird artifacts that showed up in my R viewer but disappeared when I saved as a high-res PNG. Might be worth a shot!

What do you think about these ideas? And I’m super interested to see your final plot when you get it sorted - structural equation modeling always fascinates me. What kind of model are you working on, if you don’t mind sharing?

I’ve encountered a similar issue with SemPlot before. Those unexpected lines are likely artifacts from the plotting algorithm, especially when using the ‘tree2’ layout. One workaround I found effective is switching to a different layout, like ‘tree’ or ‘circle’.

If you’re set on the ‘tree2’ layout, try adjusting the ‘edge.color’ parameter—something like edge.color = ‘black’ might help the lines blend better. Also, playing with ‘edge.width’ could minimize their visibility.

Another trick that sometimes works is tweaking the ‘nCharNodes’ and ‘nCharEdges’ parameters. Instead of 0, try setting them to a small positive number, like 1 or 2. This can sometimes clean up those pesky artifacts.

Lastly, if all else fails, you might consider using a different plotting package like ‘DiagrammeR’ or ‘ggplot2’ with ‘ggdag’. They offer more control over the final output, though there’s a bit of a learning curve.