diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index 41e05e6d9a05..a2e994ca2482 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -1016,8 +1016,11 @@ def __init__(self, ax, labels, actives=None, *, useblit=True, .. versionadded:: 3.7 - label_props : dict, optional - Dictionary of `.Text` properties to be used for the labels. + label_props : dict of lists, optional + Dictionary of `.Text` properties to be used for the labels. Each + dictionary value should be a list of at least a single element. If + the list is of length M, its values are cycled such that the Nth + label gets the (N mod M) property. .. versionadded:: 3.7 frame_props : dict, optional @@ -1117,7 +1120,8 @@ def set_label_props(self, props): Parameters ---------- props : dict - Dictionary of `.Text` properties to be used for the labels. + Dictionary of `.Text` properties to be used for the labels. Same + format as label_props argument of :class:`CheckButtons`. """ _api.check_isinstance(dict, props=props) props = _expand_text_props(props) @@ -1585,8 +1589,11 @@ def __init__(self, ax, labels, active=0, activecolor=None, *, .. versionadded:: 3.7 - label_props : dict or list of dict, optional - Dictionary of `.Text` properties to be used for the labels. + label_props : dict of lists, optional + Dictionary of `.Text` properties to be used for the labels. Each + dictionary value should be a list of at least a single element. If + the list is of length M, its values are cycled such that the Nth + label gets the (N mod M) property. .. versionadded:: 3.7 radio_props : dict, optional @@ -1695,7 +1702,8 @@ def set_label_props(self, props): Parameters ---------- props : dict - Dictionary of `.Text` properties to be used for the labels. + Dictionary of `.Text` properties to be used for the labels. Same + format as label_props argument of :class:`RadioButtons`. """ _api.check_isinstance(dict, props=props) props = _expand_text_props(props) diff --git a/lib/matplotlib/widgets.pyi b/lib/matplotlib/widgets.pyi index 0fcd1990e17e..ae88fbc5111f 100644 --- a/lib/matplotlib/widgets.pyi +++ b/lib/matplotlib/widgets.pyi @@ -154,11 +154,11 @@ class CheckButtons(AxesWidget): actives: Iterable[bool] | None = ..., *, useblit: bool = ..., - label_props: dict[str, Any] | None = ..., + label_props: dict[str, Sequence[Any]] | None = ..., frame_props: dict[str, Any] | None = ..., check_props: dict[str, Any] | None = ..., ) -> None: ... - def set_label_props(self, props: dict[str, Any]) -> None: ... + def set_label_props(self, props: dict[str, Sequence[Any]]) -> None: ... def set_frame_props(self, props: dict[str, Any]) -> None: ... def set_check_props(self, props: dict[str, Any]) -> None: ... def set_active(self, index: int, state: bool | None = ...) -> None: ... # type: ignore[override] @@ -208,10 +208,10 @@ class RadioButtons(AxesWidget): activecolor: ColorType | None = ..., *, useblit: bool = ..., - label_props: dict[str, Any] | Sequence[dict[str, Any]] | None = ..., + label_props: dict[str, Sequence[Any]] | None = ..., radio_props: dict[str, Any] | None = ..., ) -> None: ... - def set_label_props(self, props: dict[str, Any]) -> None: ... + def set_label_props(self, props: dict[str, Sequence[Any]]) -> None: ... def set_radio_props(self, props: dict[str, Any]) -> None: ... def set_active(self, index: int) -> None: ... def clear(self) -> None: ...