opendvp.pl.stacked_barplot

opendvp.pl.stacked_barplot#

stacked_barplot(df, phenotype_col, rcn_col, phenotype_colors, normalize=True, ax=None, figsize=(8, 6), **bar_kwargs)#

Plot a stacked barplot showing phenotype composition per RCN motif.

Parameters:
  • df (pandas.DataFrame) – Input dataframe containing phenotype and RCN columns.

  • phenotype_col (str) – Column name for phenotypes.

  • rcn_col (str) – Column name for RCN motifs.

  • phenotype_colors (dict) – Dictionary mapping phenotype names to colors.

  • normalize (bool, optional) – If True, normalize frequencies to proportions per motif (default: True).

  • ax (matplotlib.axes.Axes, optional) – Matplotlib Axes to plot on. If None, a new figure and axes are created.

  • figsize (tuple of int, optional) – Figure size if creating a new figure (default: (8, 6)).

  • **bar_kwargs (dict) – Additional keyword arguments passed to ax.bar.

Return type:

tuple[Figure, Axes]

Returns:

  • fig (matplotlib.figure.Figure) – The matplotlib Figure object.

  • ax (matplotlib.axes.Axes) – The matplotlib Axes object.