How to generate non-square patchwork (treemap) output?

Here it says that “patchwork” output has always a square shape: patchwork | Graphviz But to me at least it strongly seems that rectangular shapes with other aspect ratios would be way more general. So I wonder if there are any known workarounds to achive this?

Thanks in advance!

I don’t know of any. I suppose you could render to a vector and then resize to achieve a Rectangle ?

This is an interesting and apparently difficult problem.

Someone asked a similar question in StackOverflow in 2011: algorithm - Treemapping with a given aspect ratio - Stack Overflow
in which it is claimed a general solution does not exist. But we’re just interested in good results, not necessarily optimal or “perfect.”

There was some theoretical progress “Treemaps with bounded aspect ratio” 2014 but doesn’t look like a solution we would use.

Behroozi, Mohammadi and Dunne 2022 did some interesting work and might even have code that can be grafted into Graphviz if someone wants to do the work. They state, “Our optimization model is able to generate superior treemaps that could serve as a benchmark for comparing the quality of more computationally efficient algorithms” which suggests maybe their approach is not that fast, but maybe it’s fast enough. The abstract says they propose 5 algorithms. They all seem to be $O(N log N)$ so not sure if the constants are large, or what.