Restricting the width of diagrams

0 votes
asked Nov 24, 2017 in Wanted features by MSel
edited Nov 24, 2017

We use plantuml to automatically generate diagrams out of text. Sadly, the resulting diagrams happen to be too wide to fit on the desired A4-paper, while their height remains relatively low. Since the diagrams and their respective source-code are generated automatically, manipulation of single images is not an option.

Even though there are others reporting the same cause, this problem appears to be unsolved. Is there by chance a solution I have missed? Maybe an undocumented feature?

An example was omitted since it is quite wide (naturally). I can still add it, if it helps.

1 Answer

0 votes
answered Feb 20 by nikhil (820 points)

Try using -

scale 1024 width // 1024 pixels
scale 768 height // 768 pixels

Example : http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuIfEJin9LJ0rC50epqmfoK3YPwHcfcUKS74bvoGM5oiuGcadBYv71LrTEo332KmxSpc3QHUeE8nsvN98pKi1MW40

You can also try

left to right direction

In case you need to adjust on height and width.

Example : http://www.plantuml.com/plantuml/uml/JSrB2e0m30JGVKwH2nJSk1LhzI2bZROGApGHh-y71LTlCWoa5_LLzvM1QLRK3MjUacBCbOBchO04puHjq-2HewRVdUYU0WJs8cXV1m2BndHN61uTkCVnxJydwAd4w_K9

More scaling options mentioned here - http://plantuml.com/commons

Hope it helps.

commented Feb 22 by MSel
Scaling options dont seem to be helpful, since they do not affect the actual placement/layout of nodes. The resulting images are just scaled to the requirements.
(see: http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuIfEJin9LJ0rC50epqmfoU3YIiv9B2vMS8JIJbnSZWgwkdP0XXEOTkPo1jCkK74OxGhZ6y0OXd0Hk901NCmGeSoGoo4rBmNe5W00)

However, adding "left to right direction" kind of helps. The images are now much taller but narrower and a better fit for A4 paper. ( http://www.plantuml.com/plantuml/uml/HOv12e0W54Jt_nJ_0e8ksaPP7KJKKh04_T7r2r5RlPd7B6RAf1BTPu1WTqAAcFpX28rFLfEF5sIjWiM1Stoy8GUWWyePvqe9C2DZunTauG9BuLfzuzOwRq5qqnNlJlmp0PEzpFVn1G00)

Still, an option to influence the layout itsself to  would be nice. Maybe I have missed something?
commented Feb 23 by nikhil (820 points)
I am glad that "left to right direction" helped you. However, if you can explain exactly what you are facing with respect to placement/layout of nodes?
It is not clear what is expected output.

Is it something like you want to place nodes at specific levels?

To do so, you can use the options such as -

http://www.plantuml.com/plantuml/uml/RP0z3i8m38Ltdy8Ng9GChAX_t80DCKID8HPfKYL65RSdgjeoqEbxzdjwbbndCKdUemTF3q69cFZf12qd6eHZW3mOJtXI2cUsuW3oYyDaaXdHSw3hPoACILm46Bp96PkLBK23LNKkebtOGRUmN_SRBzkiDg6XLrZT75jBuMxZ71Pxzuiw3EWzK1hqVq3_BgZZmDvGL4t1bizy0G00
commented Mar 2 by MSel
Hey nikhil,
thanks for your help; i will try to give a more detailed explanation:
I wrote a plugin for LaTeX that allows users to specify a graph while writing TeX. They ismply have to specify nodes and edges with commands like "\node{myNodeA}" or "\edge{myNodeA, myNodeB}".

These commands create a graph object, which is then translated to plantuml-code and fed to the plantuml-layout-mechanism.  The graph itsself can then be displayed anywhere in the document either in all its glory ("\showGraph") or in specified parts, which only display the neighbourhood of a selected node (e.g. "\showGraph{myNodeA}").

All of this works. The problem is, that the document is specified to be printed on DinA4-Paper and plantuml happens to plot the graphs to rather wide dimensons. To fit the paper, the resulting images appear scaled only, which makes it hard to read labels (and looks funny, as well).

 I think, the problem lies within dot itsself which does not optimize its layout to fit a specified width.

As I can not manually correct every single picture (there are just too many nodes/subgraphs), I need an option to influence the layout globally.
commented Mar 2 by plantuml (184,600 points)
You are using export to Tizk, right? ( http://plantuml.com/latex )

> I think, the problem lies within dot itsself which does not optimize its layout to fit a specified width.
>
Yes, exactly. The is the real issue. And I don't think we can do anything about it.

> As I can not manually correct every single picture (there are just too many nodes/subgraphs),
>
Just a question, how do you manually correct single picture ?
commented Apr 5 by MSel
edited Apr 5
Hey plantuml,

currently I am not using Tikz. The plugin I implemented saves the graphs in dedicated datastructures and writes them to textfiles in plantuml-syntax when the document has been parsed. Subsequently, plantuml is used to generate pdfs from the textfiles, which are then fed into the second run of latex (I am using latexmk and some custom dependencies to solve this).

Since there are about hundred different pictures (with dependencies to each other) and manual correction is infeasible for me, I have never really tried. But in that case, I would try to use invisible nodes or try to direct the edges manually (e.h. -left->)

Please excuse the delayed answer.
...