opendvp.plotting.stacked_barplot

opendvp.plotting.stacked_barplot#

opendvp.plotting.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.

Return type:

tuple[Figure, Axes]

Parameters#

dfpd.DataFrame

Input dataframe containing phenotype and RCN columns.

phenotype_colstr

Column name for phenotypes.

rcn_colstr

Column name for RCN motifs.

phenotype_colorsdict

Dictionary mapping phenotype names to colors.

normalizebool, optional

If True, normalize frequencies to proportions per motif (default: True).

axmatplotlib.axes.Axes, optional

Matplotlib Axes to plot on. If None, a new figure and axes are created.

figsizetuple of int, optional

Figure size if creating a new figure (default: (8, 6)).

**bar_kwargsdict

Additional keyword arguments passed to ax.bar.

Returns:#

figmatplotlib.figure.Figure

The matplotlib Figure object.

axmatplotlib.axes.Axes

The matplotlib Axes object.