alphapepttools.pl.add_legend_to_axes_from_patches#
- alphapepttools.pl.add_legend_to_axes_from_patches(ax, patches, **kwargs)#
Add a legend with patches to an axes, using config defaults for font sizes
Automatically applies alphapepttools font sizes for legend text and title from the config unless overridden.
- Parameters:
ax (
Axes) – Matplotlib axes to add the legend topatches (
list[Patch]) – List of colored patches created bymake_legend_patches**kwargs – Additional arguments passed to
ax.legend(). Iffontsizenot provided, usesconfig["legend"]["font_size"]
- Return type:
Example
color_dict = {"WT": "blue", "KO": "red"} patches = make_legend_patches(color_dict) add_legend_to_axes_from_patches(ax, patches, title="Genotype", loc="upper right") # Legend will use config font sizes for text and title