DendrogramPlotter

class astrodendro.DendrogramPlotter(dendrogram)

Bases: object

A class to plot a dendrogram object.

Methods Summary

get_lines([structures, subtree])

Get a collection of lines to draw the dendrogram.

plot_contour(ax[, structure, subtree, slice])

Plot a contour outlining all pixels in the dendrogram, or a specific.

plot_tree(ax[, structure, subtree, autoscale])

Plot the dendrogram tree or a substructure.

set_custom_positions(custom_position)

Manually set the positon on the structures for plotting.

sort([sort_key, reverse])

Sort the position of the leaves for plotting.

Methods Documentation

get_lines(structures=None, subtree=True, **kwargs)

Get a collection of lines to draw the dendrogram.

Parameters:
structuresStructure

The structures to plot. If not set, the whole tree will be plotted.

subtreebool, optional

If a structure is specified, by default the whole subtree will be retrieved, but this can be disabled with this option.

Returns:
linesStructureCollection

The lines (sub-class of LineCollection) which can be directly used in Matplotlib

Notes

Any additional keyword arguments are passed to the ~matplotlib.collections.LineCollection class.

plot_contour(ax, structure=None, subtree=True, slice=None, **kwargs)

Plot a contour outlining all pixels in the dendrogram, or a specific. structure.

Parameters:
axAxes instance

The Axes inside which to plot the dendrogram

structureint or ~astrodendro.structure.Structure, optional

If specified, only plot this structure. This can be either the structure object itself, or the ID (idx) of the structure.

subtreebool, optional

If a structure is specified, by default the whole subtree will be plotted, but this can be disabled with this option.

sliceint, optional

If dealing with a 3-d cube, the slice at which to plot the contour. If not set, the slice containing the peak of the structure will be shown

Notes

Any additional keyword arguments are passed to ~matplotlib.axes.Axes.contour and can be used to control the appearance of the plot.

plot_tree(ax, structure=None, subtree=True, autoscale=True, **kwargs)

Plot the dendrogram tree or a substructure.

Parameters:
axAxes instance

The Axes inside which to plot the dendrogram

structureint or ~astrodendro.structure.Structure, optional

If specified, only plot this structure. This can be either the structure object itself, or the ID (idx) of the structure.

subtreebool, optional

If a structure is specified, by default the whole subtree will be plotted, but this can be disabled with this option.

autoscalebool, optional

Whether to automatically adapt the window limits to the tree

Notes

Any additional keyword arguments are passed to ~matplotlib.collections.LineCollection and can be used to control the appearance of the plot.

set_custom_positions(custom_position)

Manually set the positon on the structures for plotting.

Parameters:
custom_positionfunction

This should be a function that takes a ~astrodendro.structure.Structure`returns the position of the leaves to use for plotting. If the dataset has more than one dimension, using this may cause lines to cross. If this is used, then ``sort_key` and reverse are ignored.

sort(sort_key=None, reverse=False)

Sort the position of the leaves for plotting.

Parameters:
sort_keyfunction, optional

This should be a function that takes a ~astrodendro.structure.Structure and returns a scalar that is then used to sort the leaves. If not specified, the leaves are sorted according to their peak value.

reversebool, optional

Whether to reverse the sorting