Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 70a3f9b

Browse filesBrowse files
committed
Fixed hatching in PatchCollection class
1 parent ebbef87 commit 70a3f9b
Copy full SHA for 70a3f9b

File tree

1 file changed

+14
-9
lines changed
Filter options

1 file changed

+14
-9
lines changed

‎lib/matplotlib/collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/collections.py
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,10 +1822,13 @@ def __init__(self, patches, *, match_original=False, **kwargs):
18221822
a heterogeneous assortment of different patch types.
18231823
18241824
match_original : bool, default: False
1825-
If True, use the colors and linewidths of the original
1826-
patches. If False, new colors may be assigned by
1825+
If True, use the colors, linewidths, linestyles
1826+
and the hatch of the original patches.
1827+
If False, new colors may be assigned by
18271828
providing the standard collection arguments, facecolor,
18281829
edgecolor, linewidths, norm or cmap.
1830+
Also, all hatches will be set to the first patch's hatch,
1831+
regardless of the hatch set in the original patches.
18291832
18301833
**kwargs
18311834
All other parameters are forwarded to `.Collection`.
@@ -1843,17 +1846,19 @@ def __init__(self, patches, *, match_original=False, **kwargs):
18431846
"""
18441847

18451848
if match_original:
1846-
def determine_facecolor(patch):
1847-
if patch.get_fill():
1848-
return patch.get_facecolor()
1849-
return [0, 0, 0, 0]
1850-
1851-
kwargs['facecolors'] = [determine_facecolor(p) for p in patches]
1852-
kwargs['edgecolors'] = [p.get_edgecolor() for p in patches]
1849+
kwargs['facecolors'] = [p.get_facecolor() for p in patches]
18531850
kwargs['linewidths'] = [p.get_linewidth() for p in patches]
18541851
kwargs['linestyles'] = [p.get_linestyle() for p in patches]
18551852
kwargs['antialiaseds'] = [p.get_antialiased() for p in patches]
18561853

1854+
# Edgecolors are handled separately because are defaulted to None
1855+
# and the Hatch colors depend on them.
1856+
if any(p._original_edgecolor is not None for p in patches):
1857+
kwargs["edgecolors"] = [p.get_edgecolor() for p in patches]
1858+
1859+
# Using the hatch of only the first patch
1860+
kwargs['hatch'] = patches[0].get_hatch()
1861+
18571862
super().__init__(**kwargs)
18581863

18591864
self.set_paths(patches)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.