graphinglib.LegendPatch#
- class graphinglib.LegendPatch(label: str, face_color: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None = None, edge_color: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None = None, line_width: float = 1.0, line_style: Literal['-', '--', '-.', ':', 'solid', 'dashed', 'dashdot', 'dotted'] | tuple[float, Sequence] = '-', hatch: Literal['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'] = None, alpha: float = 1.0)[source]#
This class implements a legend patch wrapping the Patch object for creating custom legend entries with the
set_custom_legend()method. All parameters are also available as properties.- Parameters:
- labelstr
The label for the legend patch.
- face_colorColorType
The face color of the patch.
- edge_colorColorType, optional
The edge color of the patch.
- line_widthfloat, optional
The width of the patch edge and hatch (if present) in points. Typical range is
0.5to4. Defaults to1.0.- line_style{“-”, “–”, “-.”, “:”, “solid”, “dashed”, “dashdot”, “dotted”} or tuple of float and sequence, optional
The style of the patch edge, which can be any pattern supported by Matplotlib. Defaults to
"-"(solid line).- hatch{“/”, “", “|”, “-”, “+”, “x”, “o”, “O”, “.”, “*”}, optional
The hatch pattern of the patch, which can be any hatch pattern supported by Matplotlib. Values include
"/","\","|","-","+","x","o","O",".", and"*".- alphafloat, optional
The transparency level of the patch, between
0(fully transparent) and1(fully opaque). Defaults to1.0.
Notes
Color parameters accept Matplotlib color formats: named colors (
"blue"), short color strings ("b"), hex strings ("#0000ff"), grayscale strings ("0.5"), and RGB/RGBA tuples with values between0and1((0, 0, 1)or(0, 0, 1, 0.5)).Methods
__init__(label[, face_color, edge_color, ...])