is an option for TreePlot that gives a function to specify the relative height to allow for each layer.
LayerSizeFunction
is an option for TreePlot that gives a function to specify the relative height to allow for each layer.
Details
- LayerSizeFunction->f specifies that the difference of coordinates between layer n and layer
should be proportional to
. - The root or top vertices are taken to be at layer 1.
- With the default setting DataRange->Automatic, LayerSizeFunction is taken to give the actual coordinate difference between layers.
Examples
Basic Examples (1)
Draw a tree with the first level of height 1, and the second of height 2:
TreePlot[{1 -> 2, 1 -> 3, 2 -> 4, 2 -> 5, 3 -> 6, 3 -> 7}, LayerSizeFunction -> (#&)]Plot a binary tree with random layer size:
TreePlot[Flatten[Table[{i -> 2i + j - 1}, {j, 2}, {i, 2 ^ 7 - 1}]], Center, LayerSizeFunction -> (RandomReal[{-3, 3}]&)]See Also
Tech Notes
History
Text
Wolfram Research (2007), LayerSizeFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/LayerSizeFunction.html.
CMS
Wolfram Language. 2007. "LayerSizeFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LayerSizeFunction.html.
APA
Wolfram Language. (2007). LayerSizeFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LayerSizeFunction.html
BibTeX
@misc{reference.wolfram_2026_layersizefunction, author="Wolfram Research", title="{LayerSizeFunction}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/LayerSizeFunction.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_layersizefunction, organization={Wolfram Research}, title={LayerSizeFunction}, year={2007}, url={https://reference.wolfram.com/language/ref/LayerSizeFunction.html}, note=[Accessed: 13-June-2026]}