8000 minor fixes · matplotlib/matplotlib@d8cf3a0 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8cf3a0

Browse files
committed
minor fixes
1 parent f62a8ea commit d8cf3a0

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ def get_hatch(self):
994994
def get_hatch_path(self, density=6.0):
995995
"""Return a `.Path` for the current hatch."""
996996
hatch = self.get_hatch()
997-
if hatch is None or all(h is None for h in hatch):
997+
if hatch is None:
998998
return None
999999
return Path.hatch(hatch, density)
10001000

lib/matplotlib/backend_bases.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ class GraphicsContextBase:
162162
def set_gid(self, id: int | None) -> None: ...
163163
def set_snap(self, snap: bool | None) -> None: ...
164164
def set_hatch(self, hatch: str | None) -> None: ...
165-
def get_hatch(self) -> str | None | tuple[str | None]: ...
166-
def get_hatch_path(self, density: float = ...) -> Path | tuple[Path]: ...
165+
def get_hatch(self) -> str | None: ...
166+
def get_hatch_path(self, density: float = ...) -> Path: ...
167167
def get_hatch_color(self) -> ColorType: ...
168168
def set_hatch_color(self, hatch_color: ColorType) -> None: ...
169169
def get_hatch_linewidth(self) -> float: ...

lib/matplotlib/collections.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def draw(self, renderer):
385385
len(self._linewidths) == 1 and
386386
all(ls[1] is None for ls in self._linestyles) and
387387
len(self._antialiaseds) == 1 and len(self._urls) == 1 and
388-
len(self.get_hatch()) == 0):
388+
len(self.get_hatch()) == 1):
389389
if len(trans):
390390
combined_transform = transforms.Affine2D(trans[0]) + transform
391391
else:
@@ -532,9 +532,7 @@ def set_hatch(self, hatch):
532532
hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
533533
"""
534534
# Use validate_hatch(list) after deprecation.
535-
if isinstance(hatch, str):
536-
hatch = [hatch]
537-
for h in hatch:
535+
for h in np.atleast_1d(hatch):
538536
mhatch._validate_hatch_pattern(h)
539537
self._hatch = hatch
540538
self.stale = True
@@ -1871,16 +1869,12 @@ def __init__(self, patches, *, match_original=False, **kwargs):
18711869

18721870
if match_original:
18731871
kwargs['facecolors'] = [p.get_facecolor() for p in patches]
1872+
kwargs['edgecolors'] = [p.get_edgecolor() for p in patches]
18741873
kwargs['linewidths'] = [p.get_linewidth() for p in patches]
18751874
kwargs['linestyles'] = [p.get_linestyle() for p in patches]
18761875
kwargs['antialiaseds'] = [p.get_antialiased() for p in patches]
18771876
kwargs['hatch'] = [p.get_hatch() for p in patches]
18781877

1879-
# Edgecolors are handled separately because are defaulted to None
1880-
# and the Hatch colors depend on them.
1881-
if all(p._original_edgecolor is not None for p in patches):
1882-
kwargs["edgecolors"] = tuple([p.get_edgecolor() for p in patches])
1883-
18841878
super().__init__(**kwargs)
18851879

18861880
self.set_paths(patches)

0 commit comments

Comments
 (0)
0