5

Is there any way to change the orientation of the text 90º?

Example:

Initial graph:

Initial graph

Desired graph:

enter image description here

My code:

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];
}
scd
  • 212
  • 4
  • 13

2 Answers2

1

It is not possible to natively rotate labels in graphviz.

Your options may be:

1. Supply labels as images. In this case you can rotate them in your graphic editor as you want:

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>>];
}

Result:

2. If you need to rotate labels in the whole graph, you can try and draw graph rotated initially and then rotate the whole image, for example with rotate graph attribute:

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

Result:

enter image description here

Dany
  • 4,521
  • 1
  • 15
  • 32
0

Custom Font

(Only works for single letters)

  1. Load any font in a font editor (e.g fontforge)
  2. Select all glyphs and apply a 90 degree transformation
  3. Save and install the font under new name.
  4. Supply the new font to fontname in your graph.

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

Mahmoud
  • 9,729
  • 1
  • 36
  • 47