Graphviz ignores size attribute (A4 page) -
consider following minimal example graph should fit on a4 page
digraph g{ size="8.3,11.7!" ratio=fill; foo->bar; }
compile neato -tpdf -o min_ex.pdf min_ex.gv
resulting pdf file has dimensions of 236mm x 115mm , not, intended, 210mm x 297mm.
graphviz ignores attribute both graphs smaller page (like one) , ones have scaled down fit.
i have tried combinations of size
, ratio
attributes, can't graph put on a4 page of them.
so, have specify graph put on a4 page, regardless of size?
documentation:
size:
maximum width , height of drawing, in inches. if single number given, used both width , height.
if defined , drawing larger given size, drawing uniformly scaled down fits within given size.
if size ends in exclamation point (!), taken desired size. in case, if both dimensions of drawing less size, drawing scaled uniformly until @ least 1 dimension equals dimension in size.
sets aspect ratio (drawing height/drawing width) drawing. note adjusted before size attribute constraints enforced. in addition, calculations ignore node sizes, final drawing size may approximate desired.
if ratio numeric, taken desired aspect ratio. then, if actual aspect ratio less desired ratio, drawing height scaled achieve desired ratio; if actual ratio greater desired ratio, drawing width scaled up.
if ratio = "fill" , size attribute set, node positions scaled, separately in both x , y, final drawing fills specified size. if both size values exceed width , height of drawing, both coordinate values of each node scaled accordingly. however, if either size dimension smaller corresponding dimension in drawing, 1 dimension scaled final drawing has same aspect ratio specified size. then, when rendered, layout scaled down uniformly in both dimensions fit given size, may cause nodes , text shrink well. may not user wants, avoids hard problem of how reposition nodes in acceptable fashion reduce drawing size.
if ratio = "compress" , size attribute set, dot attempts compress initial layout fit in given size. achieves tighter packing of nodes reduces balance , symmetry. feature works in dot.
if ratio = "expand", size attribute set, , both width , height of graph less value in size, node positions scaled uniformly until @ least 1 dimension fits size exactly. note distinct using size desired size, here drawing expanded before edges generated , node , text sizes remain unchanged.
if ratio = "auto", page attribute set , graph cannot drawn on single page, size set ``ideal'' value. in particular, size in given dimension smallest integral multiple of page size in dimension @ least half current size. 2 dimensions scaled independently new size. feature works in dot.
the problem lies in details ratio:
note adjusted before size attribute constraints enforced. in addition, calculations ignore node sizes, final drawing size may approximate desired.
it seems graphviz
- lays out nodes as points (ignoring size)
- adjusts ratio of point nodes (still no size nodes)
- applies graph's size constraints (in our case, upscaling image): here have reached desired dimensions, we're not finished...
- then point nodes become nodes real size (by default 0.5 inch high , 0.75 inch wide)
- and whole output gets margin added
the result bigger a4.
therefore if make nodes , margin small possible, output should come relatively close a4.
setting margin
0 , node's shape
point
width
, height
minimum values following graph:
digraph g{ ratio="fill"; size="8.3,11.7!"; margin=0; node[shape=point, height=0.02, width=0.01]; foo->bar; }
neato -tpdf
graph results in pdf dimensions 211x297mm (using 8.267 inches width result in clean 210x297mm).
unfortunately, knowing how graphviz works in respect ratio=fill
, don't think there's easy way make sure final result a4 when using nodes have width , height.
Comments
Post a Comment