@@ -423,13 +423,31 @@ def draw(self, renderer):
423
423
self ._antialiaseds , self ._urls ,
424
424
"screen" )
425
425
426
- renderer .draw_path_collection (
427
- gc , transform .frozen (), paths ,
428
- self .get_transforms (), offsets , offset_trf ,
429
- self .get_facecolor (), self .get_edgecolor (),
430
- self ._linewidths , self ._linestyles ,
431
- self ._antialiaseds , self ._urls ,
432
- "screen" ) # offset_position, kept for backcompat.
426
+ fcolor = itertools .cycle (facecolors ) if facecolors .any () \
427
+ else itertools .repeat ([])
428
+ ecolor = itertools .cycle (edgecolors ) if edgecolors .any () \
429
+ else itertools .repeat ([])
430
+ lwidth = itertools .cycle (self ._linewidths )
431
+ lstyle = itertools .cycle (self ._linestyles )
432
+ antialiased = itertools .cycle (self ._antialiaseds )
433
+
434
+ if self ._match_original :
435
+ for idx in range (len (paths )):
436
+ gc .set_hatch (self ._hatch [idx ])
437
+ renderer .draw_path_collection (
438
+ gc , transform .frozen (), [paths [idx ]],
439
+ self .get_transforms (), offsets , offset_trf ,
440
+ [next (fcolor )], [next (ecolor )], [next (lwidth )], [next (lstyle )],
441
+ [next (antialiased )], self ._urls ,
442
+ "screen" ) # offset_position, kept for backcompat.
443
+ else :
444
+ renderer .draw_path_collection (
445
+ gc , transform .frozen (), paths ,
446
+ self .get_transforms (), offsets , offset_trf ,
447
+ self .get_facecolor (), self .get_edgecolor (),
448
+ self ._linewidths , self ._linestyles ,
449
+ self ._antialiaseds , self ._urls ,
450
+ "screen" )
433
451
434
452
gc .restore ()
435
453
renderer .close_group (self .__class__ .__name__ )
@@ -1868,22 +1886,21 @@ def __init__(self, patches, *, match_original=False, **kwargs):
1868
1886
a call to `~.ScalarMappable.set_array`), at draw time a call to scalar
1869
1887
mappable will be made to set the face colors.
1870
1888
"""
1889
+ self ._match_original = False
1871
1890
1872
1891
if match_original :
1892
+ self ._match_original = True
1873
1893
kwargs ['facecolors' ] = [p .get_facecolor () for p in patches ]
1874
1894
kwargs ['linewidths' ] = [p .get_linewidth () for p in patches ]
1875
1895
kwargs ['linestyles' ] = [p .get_linestyle () for p in patches ]
1876
1896
kwargs ['antialiaseds' ] = [p .get_antialiased () for p in patches ]
1897
+ kwargs ['hatch' ] = [p .get_hatch () for p in patches ]
1877
1898
1878
1899
# Edgecolors are handled separately because are defaulted to None
1879
1900
# and the Hatch colors depend on them.
1880
- if any (p ._original_edgecolor is not None for p in patches ):
1901
+ if all (p ._original_edgecolor is not None for p in patches ):
1881
1902
kwargs ["edgecolors" ] = [p .get_edgecolor () for p in patches ]
1882
1903
1883
- # Using the hatch of only the first patch
1884
- if patches :
1885
- kwargs ['hatch' ] = patches [0 ].get_hatch ()
1886
-
1887
1904
super ().__init__ (** kwargs )
1888
1905
1889
1906
self .set_paths (patches )
0 commit comments