Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
minor fixes
  • Loading branch information
r3kste committed Aug 15, 2024
commit d8cf3a025cfe8fcb70737b8db1b505458dcf3da6
2 changes: 1 addition & 1 deletion lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ def get_hatch(self):
def get_hatch_path(self, density=6.0):
"""Return a `.Path` for the current hatch."""
hatch = self.get_hatch()
if hatch is None or all(h is None for h in hatch):
if hatch is None:
return None
return Path.hatch(hatch, density)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this need to be looped if passed a list of hatches?


Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/backend_bases.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ class GraphicsContextBase:
def set_gid(self, id: int | None) -> None: ...
def set_snap(self, snap: bool | None) -> None: ...
def set_hatch(self, hatch: str | None) -> None: ...
def get_hatch(self) -> str | None | tuple[str | None]: ...
def get_hatch_path(self, density: float = ...) -> Path | tuple[Path]: ...
def get_hatch(self) -> str | None: ...
def get_hatch_path(self, density: float = ...) -> Path: ...
def get_hatch_color(self) -> ColorType: ...
def set_hatch_color(self, hatch_color: ColorType) -> None: ...
def get_hatch_linewidth(self) -> float: ...
Expand Down
12 changes: 3 additions & 9 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def draw(self, renderer):
len(self._linewidths) == 1 and
all(ls[1] is None for ls in self._linestyles) and
len(self._antialiaseds) == 1 and len(self._urls) == 1 and
len(self.get_hatch()) == 0):
len(self.get_hatch()) == 1):
if len(trans):
combined_transform = transforms.Affine2D(trans[0]) + transform
else:
Expand Down Expand Up @@ -532,9 +532,7 @@ def set_hatch(self, hatch):
hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
"""
# Use validate_hatch(list) after deprecation.
if isinstance(hatch, str):
hatch = [hatch]
for h in hatch:
for h in np.atleast_1d(hatch):
mhatch._validate_hatch_pattern(h)
self._hatch = hatch
self.stale = True
Expand Down Expand Up @@ -1871,16 +1869,12 @@ def __init__(self, patches, *, match_original=False, **kwargs):

if match_original:
kwargs['facecolors'] = [p.get_facecolor() for p in patches]
kwargs['edgecolors'] = [p.get_edgecolor() for p in patches]
kwargs['linewidths'] = [p.get_linewidth() for p in patches]
kwargs['linestyles'] = [p.get_linestyle() for p in patches]
kwargs['antialiaseds'] = [p.get_antialiased() for p in patches]
kwargs['hatch'] = [p.get_hatch() for p in patches]

# Edgecolors are handled separately because are defaulted to None
# and the Hatch colors depend on them.
if all(p._original_edgecolor is not None for p in patches):
kwargs["edgecolors"] = tuple([p.get_edgecolor() for p in patches])

super().__init__(**kwargs)

self.set_paths(patches)
Expand Down