graphinglib.LegendLine#

class graphinglib.LegendLine(label: str, 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], gap_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 = 2.0, line_style: Literal['-', '--', '-.', ':', 'solid', 'dashed', 'dashdot', 'dotted'] | tuple[float, Sequence] = '-', alpha: float = 1.0)[source]#

This class implements a legend line wrapping the Line2D 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 line.

colorColorType

The color of the line.

gap_colorColorType, optional

The color of the gaps in the line (for dashed lines).

line_widthfloat, optional

The width of the line in points. Typical range is 0.5 to 4. Defaults to 2.0.

line_style{“-”, “–”, “-.”, “:”, “solid”, “dashed”, “dashdot”, “dotted”} or tuple of float and sequence, optional

The style of the line, which can be any pattern supported by Matplotlib. Defaults to "-" (solid line).

alphafloat, optional

The transparency level of the line, between 0 (fully transparent) and 1 (fully opaque). Defaults to 1.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 between 0 and 1 ((0, 0, 1) or (0, 0, 1, 0.5)).

Methods

__init__(label, color[, gap_color, ...])