I have got a graph defined in dot format as follows:
# mwe.dot
strict graph G {
1 [ pos="-17.960000,-13.760000" label="C0" ];
2 [ pos="9.730000,5.710000" label="C1" ];
3 [ pos="-0.820000,15.530000" label="C2" ];
4 [ pos="11.090000,8.240000" label="C4" ];
5 [ pos="8.060000,11.590000" label="C5" ];
6 [ pos="-12.830000,-12.850000" label="C7" ];
7 [ pos="17.050000,-2.800000" label="C3" ];
8 [ pos="1.120000,2.300000" label="C6" ];
9 [ pos="9.070000,-13.570000" label="C8" ];
10 [ pos="13.480000,-19.740000" label="C9" ];
1 -- 6;
2 -- 3;
2 -- 4;
3 -- 5;
7 -- 8;
7 -- 9;
4 -- 5;
9 -- 10;
}
I want to render it using the x and y coordinates provided in the pos
attribute.
Running dot -Tpng mwe.dot -O -Kneato -n2
I get this:
How do I reduce the size of the labels? (The `-s' option changes nothing).
I am on a M4 Max with this graphviz version:
% dot -v
dot - graphviz version 12.2.1 (20241206.2353)
libdir = "/opt/local/lib/graphviz"
Activated plugin library: libgvplugin_dot_layout.6.dylib
Using layout: dot:dot_layout
Activated plugin library: libgvplugin_core.6.dylib
Using render: dot:core
Using device: dot:dot:core
The plugin configuration file:
/opt/local/lib/graphviz/config6
was successfully loaded.
render : cairo dot dot_json fig gd json json0 lasi map pic pov ps quartz svg svg_inline tk vrml xdot xdot_json
layout : circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
textlayout : textlayout
device : bmp canon cgimage cmap cmapx cmapx_np dot dot_json eps exr fig gd gd2 gif gv icns ico imap imap_np ismap jp2 jpe jpeg jpg json json0 kitty kittyz pct pdf pic pict plain plain-ext png pov ps ps2 psd sgi svg svg_inline svgz tga tif tiff tk vrml vt vt-24bit vt-4up vt-6up vt-8up wbmp webp x11 xdot xdot1.2 xdot1.4 xdot_json xlib
loadimage : (lib) bmp eps gd gd2 gif jpe jpeg jpg pdf png ps svg webp xbm
Update
Using the fontsize
attribute on nodes does not fix the issue: the text changes size, but the ellipses still cover the whole graph (as before).
Using this website with the nop2
layout engine (which should correspond to the neato engine with the -n2
option, afaik) does format the graph nicely. Any idea why?
The pos values are in points, not inches, so the nodes will overlap.
Also you want nop, not nop2, as you are not specifying edge layout.
scale will spread out the nodes.
Like so:
strict graph G {
layout=nop
scale=10
1 [ pos="-17.960000,-13.760000" label="C0" ];
2 [ pos="9.730000,5.710000" label="C1" ];
3 [ pos="-0.820000,15.530000" label="C2" ];
4 [ pos="11.090000,8.240000" label="C4" ];
5 [ pos="8.060000,11.590000" label="C5" ];
6 [ pos="-12.830000,-12.850000" label="C7" ];
7 [ pos="17.050000,-2.800000" label="C3" ];
8 [ pos="1.120000,2.300000" label="C6" ];
9 [ pos="9.070000,-13.570000" label="C8" ];
10 [ pos="13.480000,-19.740000" label="C9" ];
1 -- 6;
2 -- 3;
2 -- 4;
3 -- 5;
7 -- 8;
7 -- 9;
4 -- 5;
9 -- 10;
}