Welcome to PlantUML Q&A, where you can ask questions and receive answers from other members of the community.

You can also submit new features request and vote for them.

Does PlantUML expose Graphviz ratio setting?

0 votes
Hi,

I'm generating component diagrams, but they render wider than I'd like.  Is it possible to specify the Graphviz "ratio" property in PlantUML?

Thanks,

Mark
asked Sep 5, 2013 in Wanted features by mbucc (450 points)

1 Answer

0 votes

Maybe the scale command may help you: http://plantuml.sourceforge.net/commons.html#scale

Is this what you are looking for ?

 

answered Sep 5, 2013 by plantuml (126,850 points)
No, that isn't what I am looking for.

My understanding is that the scale property is applied after Graphviz does it's layout (and has defined the drawing's aspect ratio).   For example "scale 900*2000" and "scale 900*5000" both give the same output (in my test) because 900 is the tight constraint--so scale can only stretch the rectangle that Graphviz has generated either horizontally or vertically.

I would like to tell Graphviz what size I want the original drawing rectangle; for example, one that is taller than it is wide.   It looks to me like this is the ratio property: http://www.graphviz.org/doc/info/attrs.html#d:ratio
Reading the Graphviz docs more closely, it looks like supporting the "aspect" property is a better fit for what I want.   It is specifically for dealing with very wide display.

Which, by default, Graphviz tends to make:

Quoting from: http://www.graphviz.org/doc/info/attrs.html#d:aspect

Target aspect ratio (width of the layout divided by the height) of the graph drawing. If unset, dot minimizes the total edge length. For certain graphs, like those with large fan-in or fan-out, this can lead to very wide layouts. Setting aspect will cause dot to try to adjust the layout to get an aspect ratio close to that specified by aspect.

By default, dot will do 5 passes attempting to achieve the desired aspect ratio. For certain graphs, more passes will be needed to get close enough. The aspect attribute can also be used to specify the maximum number of passes to try.
Oh - that would be excellent! I hate the wide graphs I'm getting.
Previous link to aspect attribute is not correct, here is the right one: http://www.graphviz.org/content/attrs-test#daspect
Perhaps PlantUML could set a default of 4:3 or 16:9 since people mostly view these diagrams on monitors.
And optionally expose setting this value to a different value.
I just tested this.
I ran plantuml with -keepfiles, and edited svek.dot to add in the line:
aspect=1.3

I got the following warning:
Warning: dot does not support the aspect attribute for disconnected graphs or graphs with clusters

So it looks like this might not solve the problem for us. :(
Last version (V7953) contains an undocumented feature that is easier to use than -keepfiles option.
You can use an "!pragma svek_trace on" line that would create two temporary files (one .dot and one .svg). Example:

@startuml
!pragma svek_trace on
package "Package" {
node node1  {
[component1-1]
[component1-2]
[component1-3]
}
}
@enduml

You can then edit the .dot file (as you did). If you find something that improve the rendering, then tell us and we could integrate it into the .dot generation.
Hi,

   I'm very interested on this feature, because some of my diagrams are also too wide. I have experimented with this "!pragma svek_trace on" parameter and I've seen that when I add the line "ratio=0.66;" to the svek.dot file, just after the first line with "digraph unix {", the resultant PNG (generated with the dot executable) follows the ratio that I specify (0.66 in this case). It would be great if an aspect ratio could be given as a pragma parameter to the PlantUML diagrams.

   Thank you for this great product!

         Xavi
Ok, this is very easy to do.
So please find a beta
https://www.dropbox.com/s/koo42q3d9gxw288/plantuml.jar?dl=0

that supports:
!pragma ratio 0.66

Tell us if it helps!
Thanks
Good Morning,

    I couldn't test this beta version at my work, because we are not allowed to access the Dropbox website from here, but I could test it yesterday at home and it works. From what I've seen, the ratio is respected the majority of times (some diagrams with only horizontal lines were not affected by this parameter), although it usually does it by extending the vertical lines, not by changing the structure. For me it's useful and I would like to have it in a release of PlantUML, but I will continue to experiment with other possible Graphviz parameters and I will let you know if I find something better (or that complements this solution).

   Thank you and best regards!

          Xavi
Support This Project Offer 250 Mo! Follow PlantUML on Twitter
...