| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + Invalid hatch pattern characters are no longer ignored | ||
| 2 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 3 | + | ||
| 4 | + When specifying hatching patterns, characters that are not recognized will | ||
| 5 | + raise a DeprecationWarning. In the future, this will become a hard error. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | 16 | import matplotlib as mpl | |
| 17 | 17 | from . import (_path, artist, cbook, cm, colors as mcolors, docstring, | |
| 18 | - lines as mlines, path as mpath, transforms) | ||
| 18 | + hatch as mhatch, lines as mlines, path as mpath, transforms) | ||
| 19 | 19 | import warnings | |
| 20 | 20 | ||
| 21 | 21 | ||
@@ -141,8 +141,8 @@ def __init__(self, | |||
| 141 | 141 | hatch : str, optional | |
| 142 | 142 | Hatching pattern to use in filled paths, if any. Valid strings are | |
| 143 | 143 | ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See | |
| 144 | - :doc:`/gallery/shapes_and_collections/hatch_demo` for the meaning | ||
| 145 | - of each hatch type. | ||
| 144 | + :doc:`/gallery/shapes_and_collections/hatch_style_reference` for | ||
| 145 | + the meaning of each hatch type. | ||
| 146 | 146 | pickradius : float, default: 5.0 | |
| 147 | 147 | If ``pickradius <= 0``, then `.Collection.contains` will return | |
| 148 | 148 | ``True`` whenever the test point is inside of one of the polygons | |
@@ -522,6 +522,8 @@ def set_hatch(self, hatch): | |||
| 522 | 522 | ---------- | |
| 523 | 523 | hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} | |
| 524 | 524 | """ | |
| 525 | + # Use validate_hatch(list) after deprecation. | ||
| 526 | + mhatch._validate_hatch_pattern(hatch) | ||
| 525 | 527 | self._hatch = hatch | |
| 526 | 528 | self.stale = True | |
| 527 | 529 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,8 @@ | |||
| 1 | 1 | """Contains classes for generating hatch patterns.""" | |
| 2 | 2 | ||
| 3 | 3 | import numpy as np | |
| 4 | + | ||
| 5 | + from matplotlib import cbook | ||
| 4 | 6 | from matplotlib.path import Path | |
| 5 | 7 | ||
| 6 | 8 | ||
@@ -181,6 +183,22 @@ def __init__(self, hatch, density): | |||
| 181 | 183 | ] | |
| 182 | 184 | ||
| 183 | 185 | ||
| 186 | + def _validate_hatch_pattern(hatch): | ||
| 187 | + valid_hatch_patterns = set(r'-+|/\xXoO.*') | ||
| 188 | + if hatch is not None: | ||
| 189 | + invalids = set(hatch).difference(valid_hatch_patterns) | ||
| 190 | + if invalids: | ||
| 191 | + valid = ''.join(sorted(valid_hatch_patterns)) | ||
| 192 | + invalids = ''.join(sorted(invalids)) | ||
| 193 | + cbook.warn_deprecated( | ||
| 194 | + '3.4', | ||
| 195 | + message=f'hatch must consist of a string of "{valid}" or ' | ||
| 196 | + 'None, but found the following invalid values ' | ||
| 197 | + f'"{invalids}". Passing invalid values is deprecated ' | ||
| 198 | + 'since %(since)s and will become an error %(removal)s.' | ||
| 199 | + ) | ||
| 200 | + | ||
| 201 | + | ||
| 184 | 202 | def get_path(hatchpattern, density=6): | |
| 185 | 203 | """ | |
| 186 | 204 | Given a hatch specifier, *hatchpattern*, generates Path to render | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,8 @@ | |||
| 8 | 8 | import numpy as np | |
| 9 | 9 | ||
| 10 | 10 | import matplotlib as mpl | |
| 11 | - from . import artist, cbook, colors, docstring, lines as mlines, transforms | ||
| 11 | + from . import (artist, cbook, colors, docstring, hatch as mhatch, | ||
| 12 | + lines as mlines, transforms) | ||
| 12 | 13 | from .bezier import ( | |
| 13 | 14 | NonIntersectingPathException, get_cos_sin, get_intersection, | |
| 14 | 15 | get_parallels, inside_circle, make_wedged_bezier2, | |
@@ -513,6 +514,8 @@ def set_hatch(self, hatch): | |||
| 513 | 514 | ---------- | |
| 514 | 515 | hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} | |
| 515 | 516 | """ | |
| 517 | + # Use validate_hatch(list) after deprecation. | ||
| 518 | + mhatch._validate_hatch_pattern(hatch) | ||
| 516 | 519 | self._hatch = hatch | |
| 517 | 520 | self.stale = True | |
| 518 | 521 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments