ivy.vis.layers module¶
Layer functions to add to a tree plot with the addlayer method
-
ivy.vis.layers.
add_ancestor_noderecon
(treeplot, internal_vals, vis=True, colors=None, nregime=None, size=8)[source]¶ Add piecharts at each node based on probability vector
Parameters: internal_vals – - Array of dimensions [nchar+2, nnodes]. Identical to the
- format returned by anc_recon_cat
colors: List of length = nchar. The colors for each character. Optional. nregime: Number of regimes. If given and colors = None, function will automatically color-code characters by regime. (NOT IMPLEMENTED)
-
ivy.vis.layers.
add_ancrecon
(treeplot, liks, vis=True, width=2)[source]¶ Plot ancestor reconstruction for a binary mk model
-
ivy.vis.layers.
add_ancrecon_hrm
(treeplot, liks, vis=True, width=2)[source]¶ Color branches on tree based on likelihood of being in a state based on ancestral state reconstruction of a two-character, two-regime hrm model.
-
ivy.vis.layers.
add_branchstates
(treeplot, vis=True, colors=None)[source]¶ Add simulated branch states.
Treeplot must have simulated states as attributes
-
ivy.vis.layers.
add_cbar
(treeplot, nodes, vis=True, color=None, label=None, x=None, width=8, xoff=10, showlabel=True, mrca=True, leaf_valign=u'center', leaf_halign=u'left', leaf_fontsize=10, leaf_offset=4)[source]¶ Draw a ‘clade’ bar (i.e., along the y-axis) indicating a clade. nodes are assumed to be one or more nodes in the tree. If just one, it should be the internal node representing the clade of interest; otherwise, the clade of interest is the most recent common ancestor of the specified nodes. label is an optional string to be drawn next to the bar, offset by the specified number of display units. If label is
None
then the clade’s label is used instead.Parameters: - nodes – Node or list of nodes or string or list of strings.
- color (str) – Color of the bar. Optional, defaults to None. If None, will cycle through a color palette
- label (str) – Optional label for bar. If None, the clade’s label is used instead. Defaults to None.
- width (float) – Width of bar
- x (float) – Distance from tip of tree to bar. Optional, if None, calculated based on leaf labels.
- xoff (float) – Offset from label to bar
- showlabel (bool) – Whether or not to draw the label
- mrca (bool) – Whether to draw the bar encompassing all descendants
of the MRCA of
nodes
-
ivy.vis.layers.
add_circles
(treeplot, nodes, colors=u'g', size=15, xoff=0, yoff=0, vis=True)[source]¶ Draw circles on plot at nodes
Parameters: - nodes – A node object or list of Node objects or label or list of labels
- colors – Str or list of strs. Colors of the circles. Optional, defaults to ‘g’ (green)
- size (float) – Size of the circles. Optional, defaults to 15
- yoff (xoff,) – X and Y offset. Optional, defaults to 0.
-
ivy.vis.layers.
add_circles_branches
(treeplot, nodes, distances, colors=u'g', size=15, xoff=0, yoff=0, vis=True)[source]¶ Draw circles on branches
Parameters: - nodes – A node object or list of Node objects or label or list of labels
- distances – Float or list of floats indicating the distance from the parent node the branch should be drawn on.
- colors – Str or list of strs. Colors of the circles. Optional, defaults to ‘g’ (green)
- size (float) – Size of the circles. Optional, defaults to 15
- yoff (xoff,) – X and Y offset. Optional, defaults to 0.
-
ivy.vis.layers.
add_highlight
(treeplot, x=None, vis=True, width=5, color=u'red')[source]¶ Highlight nodes
Parameters:
Color branches based on likelihood of being in hidden states.
Parameters: liks (np.array) – The output of anc_recon run as a hidden-rates reconstruction.
-
ivy.vis.layers.
add_image
(treeplot, x, imgfiles, maxdim=100, border=0, xoff=4, yoff=4, halign=0.0, valign=0.5, xycoords=u'data', boxcoords=u'offset points')[source]¶ Add images to a plot at the given nodes.
Parameters: - x – Node/label or list of nodes/labels.
- imgfiles – String or list of strings of image files
Note
x and imgfiles must be the same length
-
ivy.vis.layers.
add_label
(treeplot, labeltype, vis=True, leaf_offset=4, leaf_valign=u'center', leaf_halign=u'left', leaf_fontsize=10, branch_offset=-5, branch_valign=u'center', branch_halign=u'right', fontsize=u'10')[source]¶ Add text labels to tree
Parameters: - treeplot – treeplot (fig.tree)
- labeltype (str) – “leaf” or “branch”
-
ivy.vis.layers.
add_legend
(treeplot, colors, labels, shape=u'rectangle', loc=u'upper left', **kwargs)[source]¶ Add legend mapping colors/shapes to labels
Parameters:
-
ivy.vis.layers.
add_mkmr_heatmap
(treeplot, locations, vis=True, seglen=0.02)[source]¶ Heatmap that shows which portions of the tree are most likely to contain a switchpoint
To be used with the output from mk_multi_bayes.
Parameters:
-
ivy.vis.layers.
add_node_heatmap
(treeplot, nodelist, vis=True)[source]¶ Plot circles on nodes with colors indicating how frequently each node appears in nodelist. For use with plotting potential regime shift locations
Parameters: nodelist (list) – list of node objects. Repeats allowed (and expected)
-
ivy.vis.layers.
add_phylorate
(treeplot, rates, nodeidx, vis=True)[source]¶ Add phylorate plot generated from data analyzed with BAMM (http://bamm-project.org/introduction.html)
Parameters: Warning
Ladderizing the tree can cause incorrect assignment of Ape node index numbers. To prevent this, call this function or root.ape_node_idx() before ladderizing the tree to assign correct Ape node index numbers.
-
ivy.vis.layers.
add_pie
(treeplot, node, values, colors=None, size=16, norm=True, xoff=0, yoff=0, halign=0.5, valign=0.5, xycoords=u'data', boxcoords=u'offset points', vis=True)[source]¶ Draw a pie chart
Args: node (Node): A single Node object or node label values (list): A list of floats. colors (list): A list of strings to pull colors from. Optional. size (float): Diameter of the pie chart norm (bool): Whether or not to normalize the values so they
add up to 360xoff, yoff (float): X and Y offset. Optional, defaults to 0 halign, valign (float): Horizontal and vertical alignment within
box. Optional, defaults to 0.5
-
ivy.vis.layers.
add_squares
(treeplot, nodes, colors=u'r', size=15, xoff=0, yoff=0, alpha=1.0, vis=True)[source]¶ Draw a square at given node
Parameters: - p – A node or list of nodes or string or list of strings
- colors – Str or list of strs. Colors of squares to be drawn. Optional, defaults to ‘r’ (red)
- size (float) – Size of the squares. Optional, defaults to 15
- yoff (xoff,) – Offset for x and y dimensions. Optional, defaults to 0.
- alpha (float) – between 0 and 1. Alpha transparency of squares. Optional, defaults to 1 (fully opaque)
- zorder (int) – The drawing order. Higher numbers appear on top of lower numbers. Optional, defaults to 1000.
-
ivy.vis.layers.
add_text
(treeplot, x, y, s, color=u'black', xoff=0, yoff=0, valign=u'center', halign=u'left', fontsize=10)[source]¶ Add text to the plot.
Parameters: - y (x,) – x and y coordinates to place the text
- s (str) – The text to write
- color (str) – The color of the text. Optional, defaults to “black”
- yoff (xoff,) – x and y offset
- valign (str) – Vertical alignment. Can be: ‘center’, ‘top’, ‘bottom’, or ‘baseline’. Defaults to ‘center’.
- halign (str) – Horizontal alignment. Can be: ‘center’, ‘right’, or ‘left’. Defaults to ‘left’
- fontsize (float) – Font size. Optional, defaults to 10
-
ivy.vis.layers.
add_tree_heatmap
(treeplot, locations, vis=True, color=(1, 0, 0))[source]¶ Plot how often tree coordinates appear in locations
Parameters: locations (list) – List of tuples where first item is node, second item is how far from the node’s parent the location is.
-
ivy.vis.layers.
color_blender_1
(value, start, end)[source]¶ Smooth transition between two values
value (float): Percentage along color map start: starting value of color map end: ending value of color map
-
ivy.vis.layers.
color_map
(value, col1, col2)[source]¶ Return RGB for value based on minimum and maximum colors
-
ivy.vis.layers.
colorbar_legend
(ax, values, cmap, vis=True)[source]¶ Add a vertical colorbar legend to a plot
-
ivy.vis.layers.
gradient_segment_horz
(p1, p2, c1, c2, width=4)[source]¶ Create a horizontal segment that is filled with a gradient
Parameters: Returns: list of segs and colors to be added to a LineCollection
Return type: