diff --git a/lib/matplotlib/hatch.py b/lib/matplotlib/hatch.py index 9ec88776cfd3..823b5aa93541 100644 --- a/lib/matplotlib/hatch.py +++ b/lib/matplotlib/hatch.py @@ -167,6 +167,17 @@ def __init__(self, hatch, density): self.shape_codes[0] = Path.MOVETO super().__init__(hatch, density) + +class Dashes(Shapes): + size = 0.35 + + def __init__(self, hatch, density): + self.num_rows = (hatch.count('_')) * density + path = Path([[0, 0], [1, 0]], [Path.MOVETO, Path.LINETO]) + self.shape_vertices = path.vertices + self.shape_codes = path.codes + super().__init__(hatch, density) + _hatch_types = [ HorizontalHatch, VerticalHatch, @@ -175,12 +186,13 @@ def __init__(self, hatch, density): SmallCircles, LargeCircles, SmallFilledCircles, - Stars + Stars, + Dashes ] def _validate_hatch_pattern(hatch): - valid_hatch_patterns = set(r'-+|/\xXoO.*') + valid_hatch_patterns = set(r'_-+|/\xXoO.*') if hatch is not None: invalids = set(hatch).difference(valid_hatch_patterns) if invalids: diff --git a/lib/matplotlib/hatch.pyi b/lib/matplotlib/hatch.pyi index 348cf5214984..488101689077 100644 --- a/lib/matplotlib/hatch.pyi +++ b/lib/matplotlib/hatch.pyi @@ -65,4 +65,11 @@ class Stars(Shapes): shape_codes: np.ndarray def __init__(self, hatch: str, density: int) -> None: ... +class Dashes(Shapes): + size: float + num_rows: int + shape_vertices: np.ndarray + shape_codes: np.ndarray + def __init__(self, hatch: str, density: int) -> None: ... + def get_path(hatchpattern: str, density: int = ...) -> Path: ...