graphviz dot: how to insert arrows from a node to center of an arrow

一世执手 提交于 2020-01-02 01:20:11

问题


I try to create diagrams for MPLUS analyses with dot from the graphviz package. Does anybody have experience with using dot to visualize structural equation models/latent class mixture models? There is especially one feature that I can't figure out how to do beautifully:

I need arrows from nodes to the center of another arrow like

           C
           |
           |
           V
   A ------------> B

I tried to insert an invisible node at the intersection of the arrows. This, however, results in a "cracked" A--->B arrow because dot does represent it as two independent arrows. Is this even possible with dot?

Thanks for suggestions and help!

Gregor


回答1:


Building on spenthil's answer to get rid of the kink:

digraph {
  ab[label="", fixedsize="false", width=0, height=0, shape=none];

  a -> ab[arrowhead=None];
  ab -> b;
  c -> ab;

  {rank=same; a; ab; b};
}

Output:

An other possibility would be to play with the weight attribute of the edges to straighten out edges.




回答2:


The following prevents "cracked" arrows. Dot unfortunately introduces a kink between the a -> ab and ab->b edges. Not aware of a layout algorithm that prevents this.

digraph {
  a;
  ab[label="", fixedsize="false", width=0, height=0, shape=none];
  b;
  c;

  a -> ab[arrowhead=None];
  ab -> b;
  c -> ab;
}

Output:



来源:https://stackoverflow.com/questions/3718025/graphviz-dot-how-to-insert-arrows-from-a-node-to-center-of-an-arrow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!