Skip to main content
100%

Node height

✓ Published0🌍 Public
663anp3ca
Last edited Sep 22, 2018
Created on Sep 22, 2018

This example demonstrates how TnT Tree's vertical layout determines tree height based on node size. It loads a Newick-format phylogenetic tree using `tnt.tree.parse_newick`, then renders it with a custom `node_display` that separates layout size (24 pixels) from circle drawing size (14 pixels). The layout uses `tnt.tree.layout.vertical` with a fixed width and disabled scaling, while `circle_node` controls the visual circle appearance. The code shows how providing a node display size differing from the plotted shape gives extra vertical space, affecting overall tree height calculation.

AI-generated description

By default, the layout calculates the height of the tree by using the size of the nodes. If nodes have different sizes, the maximum node size is used. All nodes are given the same space (vertical or radial depending on the layout)

In TnT Tree, all the nodes are given the same space (vertical or radial, depending on the layout) and this space is determined by the size of the nodes. If nodes are of different sizes, the maximum node size is used. For a given node, its size is determined by the maximum value between the node display and its label. In the vertical layout, the total height of the tree is given by the sum of the node heights (ie, the number of nodes times the maximum node height).

There are different ways of giving the nodes extra space, for example by giving more height to text labels. This example creates the same effect by giving the node a size different from the one that is used to plot the nodes themselves.

forked from <a href='http://bl.ocks.org/emepyc/'>emepyc</a>'s block: <a href='http://bl.ocks.org/emepyc/a0c7e747dbfb1804d4b8'>Node height</a>

mit Licensed

Similar vizzes