astrodendro.plot.DendrogramPlotter¶
-
class
astrodendro.plot.DendrogramPlotter(dendrogram)¶ A class to plot a dendrogram object.
Methods
sort([sort_key, reverse])Sort the position of the leaves for plotting. set_custom_positions(custom_position)Manually set the positon on the structures for plotting. plot_tree(ax[, structure, subtree, autoscale])Plot the dendrogram tree or a substructure. plot_contour(ax[, structure, subtree, slice])Plot a contour outlining all pixels in the dendrogram, or a specific. get_lines([structures, subtree])Get a collection of lines to draw the dendrogram. Methods (detail)
-
sort(sort_key=None, reverse=False)¶ Sort the position of the leaves for plotting.
Parameters: sort_key : function, 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.
reverse : bool, optional
Whether to reverse the sorting
-
set_custom_positions(custom_position)¶ Manually set the positon on the structures for plotting.
Parameters: custom_position : function
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
reverseare ignored.
-
plot_tree(ax, structure=None, subtree=True, autoscale=True, **kwargs)¶ Plot the dendrogram tree or a substructure.
Parameters: ax :
AxesinstanceThe Axes inside which to plot the dendrogram
structure : int 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.subtree : bool, optional
If a structure is specified, by default the whole subtree will be plotted, but this can be disabled with this option.
autoscale : bool, 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.
-
plot_contour(ax, structure=None, subtree=True, slice=None, **kwargs)¶ Plot a contour outlining all pixels in the dendrogram, or a specific. structure.
Parameters: ax :
AxesinstanceThe Axes inside which to plot the dendrogram
structure : int 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.subtree : bool, optional
If a structure is specified, by default the whole subtree will be plotted, but this can be disabled with this option.
slice : int, 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.
-
get_lines(structures=None, subtree=True, **kwargs)¶ Get a collection of lines to draw the dendrogram.
Parameters: structures :
StructureThe structures to plot. If not set, the whole tree will be plotted.
subtree : bool, optional
If a structure is specified, by default the whole subtree will be retrieved, but this can be disabled with this option.
Returns: lines :
StructureCollectionThe 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.
-