# level_set_tree.LevelSetTree.plot¶

LevelSetTree.plot(form='mass', horizontal_spacing='uniform', color_nodes=[], colormap='Dark2')

Plot the level set tree as a dendrogram and return coordinates and colors of the branches.

Parameters: form : {‘mass’, ‘density’, ‘branch-mass’}, optional Main form of the plot. ‘density’: the traditional form of the LST dendrogram where the vertical scale is density levels. ‘mass’ (default): very similar to the ‘density’ form, but draws the dendrogram based on the mass of upper (density) level sets. ‘branch-mass’: each node is drawn in the dendrogram so that its length is proportional to its mass, excluding the masses of the node’s children. In this form, the lengths of the segments representing the tree nodes sum to 1. horizontal_spacing : {‘uniform’, ‘proportional’}, optional Determines how much horizontal space each level set tree node is given. The default of “uniform” gives each child node an equal fraction of the parent node’s horizontal space. If set to ‘proportional’, then horizontal space is allocated proportionally to the mass of a node relative to its siblings. color_nodes : list, optional Nodes to color in the level set tree. For each node, the subtree for which that node is the root is drawn with a single color. colormap : str, optional Matplotlib colormap, used only if ‘color_nodes’ contains at least one node index. Default is the ‘Dark2’ colormap. “Qualitative” colormaps are highly recommended. fig : matplotlib figure Use fig.show() to view, fig.savefig() to save, etc. node_colors : dict RGBA 4-tuple node_coords : dict Coordinates of vertical line segment endpoints representing LST nodes. split_coords : dict Coordinates of horizontal line segment endpoints, representing splits in the level set tree. There is a horizontal line segment for each child in a split, and the keys in the ‘split_coords’ dictionary indicate to which child the line segment belongs.

Examples

>>> X = numpy.random.rand(100, 2)
>>> tree = debacl.construct_tree(X, k=8, prune_threshold=5)
>>> plot = tree.plot(form='density')
>>> fig = plot[0]
>>> fig.show()