diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index 76a7c0d5af81..eb689ef661c7 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -161,11 +161,11 @@ class MarkerStyle: Attributes ---------- - markers : list + markers : dict All known markers. - filled_markers : list + filled_markers : tuple All known filled markers. This is a subset of *markers*. - fillstyles : list + fillstyles : tuple The supported fillstyles. """ @@ -241,16 +241,16 @@ def __init__(self, marker, Transform that will be combined with the native transform of the marker. - capstyle : CapStyle, default: None + capstyle : `.CapStyle` or %(CapStyle)s, default: None Cap style that will override the default cap style of the marker. - joinstyle : JoinStyle, default: None + joinstyle : `.JoinStyle` or %(JoinStyle)s, default: None Join style that will override the default join style of the marker. """ self._marker_function = None self._user_transform = transform - self._user_capstyle = capstyle - self._user_joinstyle = joinstyle + self._user_capstyle = CapStyle(capstyle) if capstyle is not None else None + self._user_joinstyle = JoinStyle(joinstyle) if joinstyle is not None else None self._set_fillstyle(fillstyle) self._set_marker(marker) diff --git a/lib/matplotlib/markers.pyi b/lib/matplotlib/markers.pyi index f6cb3f919ccd..3ee538838514 100644 --- a/lib/matplotlib/markers.pyi +++ b/lib/matplotlib/markers.pyi @@ -1,9 +1,10 @@ -from ._enums import CapStyle, JoinStyle +from typing import Literal + from .path import Path from .transforms import Affine2D, Transform from numpy.typing import ArrayLike -from .typing import FillStyleType +from .typing import CapStyleType, FillStyleType, JoinStyleType TICKLEFT: int TICKRIGHT: int @@ -28,20 +29,18 @@ class MarkerStyle: marker: str | ArrayLike | Path | MarkerStyle | None, fillstyle: FillStyleType | None = ..., transform: Transform | None = ..., - capstyle: CapStyle | None = ..., - joinstyle: JoinStyle | None = ..., + capstyle: CapStyleType | None = ..., + joinstyle: JoinStyleType | None = ..., ) -> None: ... def __bool__(self) -> bool: ... def is_filled(self) -> bool: ... - def get_fillstyle( - self, - ) -> FillStyleType: ... - def get_joinstyle(self) -> JoinStyle: ... - def get_capstyle(self) -> CapStyle: ... - def get_marker(self) -> str | ArrayLike | Path | MarkerStyle | None: ... + def get_fillstyle(self) -> FillStyleType: ... + def get_joinstyle(self) -> Literal["miter", "round", "bevel"]: ... + def get_capstyle(self) -> Literal["butt", "projecting", "round"]: ... + def get_marker(self) -> str | ArrayLike | Path | None: ... def get_path(self) -> Path: ... def get_transform(self) -> Transform: ... - def get_alt_path(self) -> Path: ... + def get_alt_path(self) -> Path | None: ... def get_alt_transform(self) -> Transform: ... def get_snap_threshold(self) -> float | None: ... def get_user_transform(self) -> Transform | None: ... diff --git a/lib/matplotlib/tests/test_marker.py b/lib/matplotlib/tests/test_marker.py index 22d619d395fe..13f977dc38f1 100644 --- a/lib/matplotlib/tests/test_marker.py +++ b/lib/matplotlib/tests/test_marker.py @@ -207,18 +207,16 @@ def test_marker_init_transforms(): def test_marker_init_joinstyle(): marker = markers.MarkerStyle("*") - jstl = markers.JoinStyle.round - styled_marker = markers.MarkerStyle("*", joinstyle=jstl) - assert styled_marker.get_joinstyle() == jstl - assert marker.get_joinstyle() != jstl + styled_marker = markers.MarkerStyle("*", joinstyle="round") + assert styled_marker.get_joinstyle() == "round" + assert marker.get_joinstyle() != "round" def test_marker_init_captyle(): marker = markers.MarkerStyle("*") - capstl = markers.CapStyle.round - styled_marker = markers.MarkerStyle("*", capstyle=capstl) - assert styled_marker.get_capstyle() == capstl - assert marker.get_capstyle() != capstl + styled_marker = markers.MarkerStyle("*", capstyle="round") + assert styled_marker.get_capstyle() == "round" + assert marker.get_capstyle() != "round" @pytest.mark.parametrize("marker,transform,expected", [
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: