pycea.pl.n_extant

Contents

pycea.pl.n_extant#

pycea.pl.n_extant(tdata, color=None, *, data=None, key='n_extant', depth_key=None, n_extant_key=None, stat='count', order=None, palette=None, na_color='lightgray', legend=None, ax=None, legend_kwargs=None)#

Plot extant branches over time.

Parameters:
  • tdata (TreeData) – The TreeData object.

  • color (Sequence[str] | str | None (default: None)) – Column(s) in data to color by. Determined from data when None.

  • data (DataFrame | None (default: None)) – Extant counts to plot. Uses tdata.uns[key] if None.

  • key (str (default: 'n_extant')) – Key in tdata.uns storing extant counts when data is None.

  • depth_key (str | None (default: None)) – Column storing time or depth values. If None, uses the first column in data.

  • n_extant_key (str | None (default: None)) – Column storing extant counts. If None, uses the second column in data.

  • stat (Literal['count', 'proportion', 'percent'] (default: 'count')) – Statistic to compute for the ribbons: ‘count’, ‘fraction’, or ‘percent’.

  • order (Sequence[str] | None (default: None)) – Order of group categories in the stack.

  • palette (dict[str, str] | None (default: None)) – Colors to use for plotting categorical annotation groups. The palette can be a valid ListedColormap name ('Set2', 'tab20', …), a Cycler object, a dict mapping categories to colors, or a sequence of colors. Colors must be valid to matplotlib. (see is_color_like()). If None, mpl.rcParams["axes.prop_cycle"] is used unless the categorical variable already has colors stored in tdata.uns["{var}_colors"]. If provided, values of tdata.uns["{var}_colors"] will be set.

  • na_color (str | None (default: 'lightgray')) – The color to use for annotations with missing data.

  • legend (bool | None (default: None)) – Whether to add a legend to the plot. By default, a legend is added if there are <= 20 distinct categories.

  • ax (Axes | None (default: None)) – Axes on which to draw the plot. Creates new axes when None.

  • legend_kwargs (dict[str, Any] | None (default: None)) – Additional keyword arguments for the legend.

Return type:

Axes

Returns:

ax - Axis containing the ribbon plot.