# Horizontal Tree Layout? [duplicate]

I need to display arbitrary Expressions in TreeForm, but the standard vertical layout produces too many horizontally overlapping boxes. Am I doomed to rewriting expressions as graphs and using TreePlot and GraphPlot and going down this road

http://www.wolfram.com/technology/guide/FullyAutomatedGraphLayout/

or is there something I can do in a hurry to make TreeForm look better?

Docs say

TreeForm takes the same options as TreePlot.


so I pop over to TreePlot and see

TreePlot[{1 -> 4, 1 -> 6, 1 -> 8, 2 -> 6, {3 -> 8, "3\[Rule]8"},
4 -> 5, 7 -> 8}, Left]


go back to TreeForm and try

TreeForm[a + b^2 + c^3 + d, Left]


but oops:

TreeForm::tlev: Warning: level specification Left is not a non-negative integer or
Infinity; ignored. >>

-

## marked as duplicate by bobthechemist, Dr. belisarius, ciao, Sjoerd C. de Vries, m_goldbergApr 11 '14 at 21:30

Isn't this a duplicate of Can TreeForm be displayed “sideways”? – Rahul Apr 11 '14 at 0:48
Left is not an option, it's a parameter. – Sjoerd C. de Vries Apr 11 '14 at 20:33

Generally - arbitrary-angle layout:

Rotate[ ... /. x_Framed -> Rotate[x, -angle], angle]


Now you can do it like this:

Rotate[ToExpression@ToBoxes@TreeForm[a + b^2 + c^3 + d] /.
x_Framed -> Rotate[x, -Pi/2], Pi/2]


Or like this:

P.S. =========================

Manipulate code for the record

Manipulate[Show[Rasterize@
Rotate[ToExpression@ToBoxes@TreeForm[a + b^2 + c^3 + d] /.
x_Framed -> Rotate[x, -ang], ang],
ImageSize -> 200 {1, 1}],
{ang, 0, 2 Pi}]

-
ouch...totally ignored Rotate. yes, that makes absolutely sense. – Stefan Apr 10 '14 at 19:39
This is a really good instance of "thinking out of the box" -- composing some generic but display-specific functions (/slaps forehead) – Reb.Cabin Apr 10 '14 at 20:54
Interesting that the Rotate works when the TreeForm graphic is pasted directly into the Rotate call, but the following does not work (because it doesn't rotate the internal framed bits) Rotate[TreeForm[a+b^2+c^3+d], /. x_Framed -> Rotate[Framed[x], -Pi/2], Pi/2] – Reb.Cabin Apr 10 '14 at 21:17
This code adds an extra frame. You only need Rotate[ ... /. x_Framed -> Rotate[x, -Pi/2], Pi/2] – ArgentoSapiens Apr 10 '14 at 22:04
@ArgentoSapiens thank you, corrected. – Vitaliy Kaurov Apr 11 '14 at 14:43

I don't know if this is by any means what you're looking for, but you can use VertexCoordinateRules to determine the coordinates at which vertices should be placed:

TreeForm[a + b^2 + c^3 + d,
VertexCoordinateRules -> {{1, 4}, {2, 8}, {3, 8}, {4, 10}, {4, 6}, {3, 0},
{4, 3}, {4, -2}, {2, 0}}]


-