graphinglib.SmartFigureWCS.set_custom_legend#

SmartFigureWCS.set_custom_legend(elements: Iterable[LegendElement] | None = None, reset: bool = False) Self#

Sets a custom legend for the figure. If the SmartFigure contains multiple subplots, custom legends only work if the ``general_legend`` parameter is set to ``True``. Otherwise, custom legends can be added for non-general legends if the SmartFigure is currently used as a single plot (see the is_single_subplot property).

Note

The visibility of default or custom legend elements can be controlled individually with the hide_default_legend_elements and hide_custom_legend_elements properties.

Parameters:
elementsIterable[LegendElement], optional

Iterable of LegendElement objects to add to the legend.

resetbool, optional

If True, resets all previously set custom handles and labels before adding the new ones. Defaults to False.

Returns:
Self

For convenience, the same SmartFigure with the updated custom legend.