alphapepttools.pl.add_legend_to_axes_from_patches

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 to

  • patches (list[Patch]) – List of colored patches created by make_legend_patches

  • **kwargs – Additional arguments passed to ax.legend(). If fontsize not provided, uses config["legend"]["font_size"]

Return type:

None

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