@@ -388,10 +388,11 @@ def draw(self, renderer):
388388 trans = self .get_transforms ()
389389 facecolors = self .get_facecolor ()
390390 edgecolors = self .get_edgecolor ()
391+ linewidths = np .nan_to_num (self ._linewidths , nan = 0 , posinf = 0 ).clip (0 )
391392 do_single_path_optimization = False
392393 if (len (paths ) == 1 and len (trans ) <= 1 and
393394 len (facecolors ) == 1 and len (edgecolors ) == 1 and
394- len (self . _linewidths ) == 1 and
395+ len (linewidths ) == 1 and
395396 all (ls [1 ] is None for ls in self ._linestyles ) and
396397 len (self ._antialiaseds ) == 1 and len (self ._urls ) == 1 and
397398 self .get_hatch () is None ):
@@ -412,7 +413,7 @@ def draw(self, renderer):
412413
413414 if do_single_path_optimization :
414415 gc .set_foreground (tuple (edgecolors [0 ]))
415- gc .set_linewidth (self . _linewidths [0 ])
416+ gc .set_linewidth (linewidths [0 ])
416417 gc .set_dashes (* self ._linestyles [0 ])
417418 gc .set_antialiased (self ._antialiaseds [0 ])
418419 gc .set_url (self ._urls [0 ])
@@ -433,7 +434,7 @@ def draw(self, renderer):
433434 gc , transform .frozen (), [],
434435 self .get_transforms (), offsets , offset_trf ,
435436 self .get_facecolor (), self .get_edgecolor (),
436- self . _linewidths , self ._linestyles ,
437+ linewidths , self ._linestyles ,
437438 self ._antialiaseds , self ._urls ,
438439 "screen" , hatchcolors = self .get_hatchcolor ()
439440 )
@@ -453,7 +454,7 @@ def draw(self, renderer):
453454 # First draw paths within the gaps.
454455 ipaths , ilinestyles = self ._get_inverse_paths_linestyles ()
455456 args = [offsets , offset_trf , [mcolors .to_rgba ("none" )], self ._gapcolor ,
456- self . _linewidths , ilinestyles , self ._antialiaseds , self ._urls ,
457+ linewidths , ilinestyles , self ._antialiaseds , self ._urls ,
457458 "screen" ]
458459
459460 if hatchcolors_arg_supported :
@@ -478,7 +479,7 @@ def draw(self, renderer):
478479 renderer .draw_path (gc0 , path , transform , rgbFace )
479480
480481 args = [offsets , offset_trf , self .get_facecolor (), self .get_edgecolor (),
481- self . _linewidths , self ._linestyles , self ._antialiaseds , self ._urls ,
482+ linewidths , self ._linestyles , self ._antialiaseds , self ._urls ,
482483 "screen" ]
483484
484485 if hatchcolors_arg_supported :
0 commit comments