Plotting Merger Trees¶
Some relatively simple visualizations of merger trees can be made with
the TreePlot
command.
Additional Dependencies¶
Making merger tree plots with ytree
requires the
pydot and
graphviz packages. pydot
can be
installed with pip
and the
graphviz website provides a number
of installation options.
Making Tree Plots¶
The TreePlot
command can be
used to create a digraph
depicting halos as filled circles with sizes proportional to their mass.
The main progenitor line will be colored red.
>>> import ytree
>>> a = ytree.load("ahf_halos/snap_N64L16_000.parameter",
... hubble_constant=0.7)
>>> p = ytree.TreePlot(a[0], dot_kwargs={'rankdir': 'LR', 'size': '"12,4"'})
>>> p.save('tree.png')
Plot Modifications¶
Four TreePlot
attributes can be set
to modify the default plotting behavior. These are:
- size_field: The field to determine the size of each circle. Default: ‘mass’.
- size_log: Whether to scale circle sizes based on log of size field. Default: True.
- min_mass: The minimum halo mass to be included in the plot. If given as a float, units are assumed to be Msun. Default: None.
- min_mass_ratio: The minimum ratio between a halo’s mass and the mass of the main halo to be included in the plot. Default: None.
>>> import ytree
>>> a = ytree.load("ahf_halos/snap_N64L16_000.parameter",
... hubble_constant=0.7)
>>> p = ytree.TreePlot(a[0], dot_kwargs={'rankdir': 'LR', 'size': '"12,4"'})
>>> p.min_mass_ratio = 0.01
>>> p.save('tree_small.png')