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 (790 points)

Try using -

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

Example :

You can also try

left to right direction

In case you need to adjust on height and width.

Example :

More scaling options mentioned here -

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.

However, adding "left to right direction" kind of helps. The images are now much taller but narrower and a better fit for A4 paper. (

Still, an option to influence the layout itsself to  would be nice. Maybe I have missed something?
commented Feb 23 by nikhil (790 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 -
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 (160,740 points)
You are using export to Tizk, right? ( )

> 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.