FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update hatch.py by Arikad0 · Pull Request #27337 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
21 changes: 19 additions & 2 deletions lib/matplotlib/hatch.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ def __init__(self, hatch, density):
self.shape_codes[0] = Path.MOVETO
super().__init__(hatch, density)

class DashedHatch(HatchPatternBase):
def __init__(self, hatch, density):
self.num_lines = int((hatch.count('_') + hatch.count('+')) * density)
self.num_vertices = self.num_lines * 2

def set_vertices_and_codes(self, vertices, codes):
steps, stepsize = np.linspace(0.0, 1.0, self.num_lines, False,
retstep=True)
steps += stepsize / 2.
vertices[0::2, 0] = steps
vertices[0::2, 1] = 0.0
vertices[1::2, 0] = steps
vertices[1::2, 1] = 1.0
codes[0::2] = Path.MOVETO
codes[1::2] = Path.LINETO

_hatch_types = [
HorizontalHatch,
VerticalHatch,
Expand All @@ -175,12 +191,13 @@ def __init__(self, hatch, density):
SmallCircles,
LargeCircles,
SmallFilledCircles,
Stars
Stars,
DashedHatch
]


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:
Expand Down

Back | FazBrowse Home | New Git URL