对齐节点,使标签保持边缘

时间:2018-11-05 16:14:34

标签: graphviz dot

我有以下模型:

strict digraph graphName {
  rankdir="LR";
  splines="curved";

  age -> intention [label="-"];
  attitude -> intention [label="+"];
  education -> intention [label="+"];
  env_friendly -> intention [label="+"];
  knowledge -> intention [label="+"];
  male
  negative -> intention [label="-"];
  neutral
  positive -> intention [label="+"];
  unsafe -> intention [label="-"];

  positive -> env_friendly [dir="both", label="+"];

  { rank = same; age; attitude; education; env_friendly; knowledge; male; negative; neutral; positive; unsafe; }
}

这将显示OK,但是边缘标签关闭,并且双箭头进入节点而不是节点边缘。我该怎么做才能使标签随节点一起返回?

enter image description here

1 个答案:

答案 0 :(得分:0)

只需删除行splines = "curved";即可得到(我想)您想要的:

strict digraph graphName {
  rankdir="LR";
  # splines="curved";

  age -> intention [label="-"];
  attitude -> intention [label="+"];
  education -> intention [label="+"];
  env_friendly -> intention [label="+"];
  knowledge -> intention [label="+"];
  male
  negative -> intention [label="-"];
  neutral
  positive -> intention [label="+"];
  unsafe -> intention [label="-"];

  positive -> env_friendly [dir="both", label="+"];

  { rank = same; age; attitude; education; env_friendly; knowledge; male; negative; neutral; positive; unsafe; }
}

收益

enter image description here

提示来自graphviz的警告

  

警告:点中不支持带有样条曲线=曲线的边缘标签-请使用xlabels

但关键是不使用xlabels,而是不使用splines