publiplots.create_legend_handles#
- publiplots.create_legend_handles(labels, colors=None, edgecolors=None, hatches=None, sizes=None, markers=None, linestyles=None, alpha=None, linewidth=None, markeredgewidth=None, style='rectangle', color=None)[source]#
Create custom legend handles with alpha and linewidth embedded.
- Parameters:
labels (List[str]) – Labels for each legend entry.
colors (List[str], optional) – Colors for each legend entry.
edgecolors (str or List[str], optional) – Edge colors for each legend entry. If None, defaults to colors. If str, broadcasts to all entries. If list, one per entry.
hatches (List[str], optional) – Hatch patterns for each legend entry (for rectangles).
sizes (List[float], optional) – Sizes for each legend entry (markersizes).
markers (List[str], optional) – Marker symbols for each legend entry (e.g., [‘o’, ‘^’, ‘s’]). If provided with linestyles, creates LineMarkerPatch handles. If provided without linestyles, creates MarkerPatch handles.
linestyles (List[str], optional) – Line styles for each legend entry (e.g., [‘-’, ‘–’, ‘:’]). If provided with markers, creates LineMarkerPatch handles.
alpha (float, optional) – Transparency level for fill layers. When omitted it falls back to
rcParams["alpha"](0.1).linewidth (float, optional) – Stroke width of the swatch. Applies to whichever stroke the chosen patch type draws: the shape outline for rectangle/marker swatches, or the line itself for line and line+marker swatches. When omitted it falls back per patch type –
rcParams["edgewidth"]for an outline,rcParams["lines.linewidth"]for a line.markeredgewidth (float, optional) – Width of marker edges — an outline, so when omitted it falls back to
rcParams["edgewidth"](0.75).style (str, default="rectangle") – Style of legend markers: “rectangle”, “circle”, “marker”, or “line”. Ignored if markers parameter is provided.
color (str, optional) – Single color for all entries if colors not provided.
- Returns:
List of Patch objects with embedded properties.
- Return type:
List[Patch]