@@ -420,25 +420,40 @@ def draw(self, renderer):
420420 gc , paths [0 ], combined_transform .frozen (),
421421 mpath .Path (offsets ), offset_trf , tuple (facecolors [0 ]))
422422 else :
423- if self . _gapcolor is not None :
424- # First draw paths within the gaps.
425- ipaths , ilinestyles = self . _get_inverse_paths_linestyles ()
423+ # Find whether renderer.draw_path_collection() takes hatchcolor parameter
424+ hatchcolors_arg_supported = True
425+ try :
426426 renderer .draw_path_collection (
427- gc , transform .frozen (), ipaths ,
427+ gc , transform .frozen (), [] ,
428428 self .get_transforms (), offsets , offset_trf ,
429- [ mcolors . to_rgba ( "none" )] , self ._gapcolor ,
430- self ._linewidths , ilinestyles ,
429+ self . get_facecolor () , self .get_edgecolor () ,
430+ self ._linewidths , self . _linestyles ,
431431 self ._antialiaseds , self ._urls ,
432- "screen" , self .get_hatchcolor ())
433-
434- renderer .draw_path_collection (
435- gc , transform .frozen (), paths ,
436- self .get_transforms (), offsets , offset_trf ,
437- self .get_facecolor (), self .get_edgecolor (),
438- self ._linewidths , self ._linestyles ,
439- self ._antialiaseds , self ._urls ,
440- "screen" , # offset_position, kept for backcompat.
441- self .get_hatchcolor ())
432+ "screen" , self .get_hatchcolor ()
433+ )
434+ except TypeError :
435+ hatchcolors_arg_supported = False
436+
437+ if self ._gapcolor is not None :
438+ # First draw paths within the gaps.
439+ ipaths , ilinestyles = self ._get_inverse_paths_linestyles ()
440+ args = [gc , transform .frozen (), ipaths , self .get_transforms (),
441+ offsets , offset_trf , [mcolors .to_rgba ("none" )],
442+ self ._gapcolor , self ._linewidths , ilinestyles ,
443+ self ._antialiaseds , self ._urls , "screen" ]
444+ if hatchcolors_arg_supported :
445+ args .append (self .get_hatchcolor ())
446+
447+ renderer .draw_path_collection (* args )
448+
449+ args = [gc , transform .frozen (), paths , self .get_transforms (),
450+ offsets , offset_trf , self .get_facecolor (),
451+ self .get_edgecolor (), self ._linewidths , self ._linestyles ,
452+ self ._antialiaseds , self ._urls , "screen" ]
453+ if hatchcolors_arg_supported :
454+ args .append (self .get_hatchcolor ())
455+
456+ renderer .draw_path_collection (* args )
442457
443458 gc .restore ()
444459 renderer .close_group (self .__class__ .__name__ )
0 commit comments