在Graphviz中将节点标签方向旋转90度

5

有没有办法将文本的方向改变90º?

例如:

初始图像:

初始图像

期望图像:

输入图像描述

我的代码:

digraph G {
  layout="neato"
  edge[arrowhead=none]
  node[style=filled fillcolor="white", fixedsize=true]
  circunferencia[label="", pos="0.0, 0.0!", shape = "circle", width=2, color="grey", style=boldsi];
  1[label="1()", pos="0.30901699437494745,0.9510565162951535!", shape = "circle"];
  5[label="5()", pos="-0.8090169943749473,0.5877852522924732!", shape = "circle"];
  4[label="4()", pos="-0.8090169943749476,-0.587785252292473!", shape = "circle"];
  3[label="3()", pos="0.30901699437494723,-0.9510565162951536!", shape = "circle"];
  2[label="2()", pos="1.0,-2.4492935982947064e-16!", shape = "circle"];
  centro[label="", pos="0.0, 0.0!", shape = "point", fillcolor=black];
}

展示你的代码。如果我们能看到你正在使用什么,那么推荐东西会更容易些。 - TomServo
这里是你需要的内容,希望你能帮助我。 - scd
2个回答

1
无法在Graphviz中原生旋转标签。
您的选择可能是: 1. 以图像形式提供标签。在这种情况下,您可以在图形编辑器中按照需要旋转它们:
digraph {
    a [
        image="one.png"
        label=""
    ]
    b [
        image="two.png"
        label=""
    ]
    a -> b [label=<<TABLE border="0">
    <TR><TD><IMG SRC="rot.png"/></TD></TR>
    </TABLE>>];
}

结果:

2. 如果您需要旋转整个图表中的标签,可以尝试先绘制旋转后的图表,然后再旋转整个图像,例如使用 rotate 图表属性:

digraph {
    rotate=90
    a [
        label="One"
    ]
    b [
        label="Two"
    ]
    a -> b [label="label"];
}

结果:

enter image description here


1
我只是想更改文本,而不是整个图表。 - scd

0

自定义字体

(仅适用于单个字母)

  1. 在字体编辑器中加载任何字体(例如fontforge
  2. 选择所有字形并应用90度旋转
  3. 另存为新名称的字体并安装
  4. 将新字体提供给您的图表中的fontname

Arial_rotated

digraph G {
  layout="neato"
  edge[arrowhead=none]
  node[style=filled fillcolor="white", fixedsize=true, fontname="Arial_rotated"]
  circunferencia[label="", pos="0.0, 0.0!", shape = "circle", width=2, color="grey", style=boldsi];
  1[label="1", pos="0.30901699437494745,0.9510565162951535!", shape = "circle"];
  5[label="5", pos="-0.8090169943749473,0.5877852522924732!", shape = "circle"];
  4[label="4", pos="-0.8090169943749476,-0.587785252292473!", shape = "circle"];
  3[label="3", pos="0.30901699437494723,-0.9510565162951536!", shape = "circle"];
  2[label="2", pos="1.0,-2.4492935982947064e-16!", shape = "circle"];
  centro[label="", pos="0.0, 0.0!", shape = "point", fillcolor=black];
}

preview rotated


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接